Spain's right stormed to its biggest election win ever, unleashing dancing in the street by voters desperate for an end to soaring unemployment and a eurozone debt storm.
Mariano Rajoy, the bearded 56-year-old leader of the conservative Popular Party, gave a modest jump for joy as he proclaimed victory.
"Forty-six million Spaniards are going to wage a battle against the crisis," he told a sea of cheering supporters from a balcony outside the party headquarters in Madrid.
"The work that lies ahead us will not be easy, but I want you to know I am convinced that with the help of everyone we will move forward and Spain will be where we all want it to be -- at the head of Europe."
Drivers blared car horns in the capital's streets as the scale of the victory became clear.
Voters handed the ruling Socialists their biggest defeat in history, chasing them from seven years in office in which an economic boom went bust and the unemployment rate shot to 21.5 percent.
"The Socialist Party did not have a good result. We clearly lost the elections," the party's candidate for premier, 60-year-old Alfredo Perez Rubalcaba, told supporters.
Spain's government was the last to fall among the eurozone's so-called periphery nations this year after Ireland, Portugal, Greece and Italy all succumbed to a collapse of confidence in their sovereign debt.
With more than 99 percent of the ballots counted, Rajoy's Popular Party had 44.60 percent of the vote and an absolute majority of 186 seats in the 350-member Congress of Deputies.
The win gives Rajoy a free hand to ram through severe austerity measures in the eurozone's fourth biggest economy.
The Socialists won 28.73 percent of the vote, giving them 110 seats, the count showed.
"Spain needed a change. We have had eight years of a failed government," said 16-year-old high school student Jorge Alises who carried a Partido Popular flag as well as a red and yellow Spanish one.
"I have a lot of faith in Rajoy's team. They are very focused on Spain's main problem, which is the economy."
Though considered uncharismatic, Rajoy won support from voters lured by his promise to fix the economy and create jobs, even if it means more austerity.
He has vowed to make cuts "everywhere", except for pensions, so as to meet Spain's target of cutting the public deficit to 4.4 percent of gross domestic product in 2012 from 9.3 percent last year.
Analysts say Rajoy, who will be sworn in from December 20, must quickly impose reforms to reassure world markets.
Spain's risk premium -- the extra interest rate investors demand to buy Spanish compared with safe-haven German debt -- shot to a euro-era high of more than 500 basis points in the days ahead of the vote.
French President Nicolas Sarkozy called Rajoy to congratulate him on the win and said that he wanted to give "new momentum to a particularly rich partnership".
Spain and France could "work together as Europe faces an unprecedented financial and economic crisis," he added.
"Together with our partners we must give an efficient and credible response to restore stability and growth in the eurozone."
British Prime Minister David Cameron also called Rajoy and congratulated him for "winning a crucial argument at a vital time for Spain and Europe," said a Downing Sreet statement.
Spanish Prime Minister Jose Luis Rodriguez Zapatero's government was blamed for reacting too late to the 2008 property market implosion, which combined with a global financial crisis to throw millions out of work.
As his government battled to cut back spending and avoid a disastrous loss of confidence by the debt markets, it cut public sector wages by an average 5.0 percent, froze pensions and raised the retirement age from 65 to 67.
Zapatero called the election four months early to give a new government the chance to confront the crisis. After two terms in office, he decided not to run again.
A nationwide protest movement erupted in May 2011 to vent anger over the high jobless rate and political corruption.
Hundreds of "indignant" protesters rallied in Madrid in the days before the election and analysts say many more may flood the streets next year if spending cuts go even deeper.
In a sign of frustration with the two big parties, the United Left coalition of lefts and greens won 1.67 million votes, increasing their seats in the lower house from two to 11.