Alan Garcia will be the next president of Peru. That much is clear.
By Daniel Schweimler
BBC News, Lima
Alan Garcia must build bridges between Peru's rich and poor
But quite how the man who had a disastrous term as president between 1985 and 1990 has managed to work his way back into office, has left many Peruvians scratching their heads in bewilderment.
He left the post with inflation at 7,000%, the country involved in a bloody conflict with Maoist rebels and accusations of corruption levelled at
The political career of Alan Garcia, Peru's youngest president at 35, appeared to be over.
But a remarkable set of circumstances has seen him voted back into power and fairly convincingly. In the first round of the election in April the majority of the vote was split three ways.
The nationalist former army officer Ollanta Humala won first place with more than 30% of the vote, appealing mostly to Peru's poor and indigenous community.
The battle for second place was between Mr Garcia and a conservative woman, Lourdes Flores. She appealed to the business community, the Lima elite and had trouble striking up any kind of relationship with Peru's poor.
Alan Garcia scraped through with just a few thousand votes more than his rival who was eliminated from the contest.
That left just two men. The political and physical heavyweight, Alan Garcia, and the diminutive political novice, Ollanta Humala. Mr Garcia knows all the tricks in the book and can hold an audience in the palm of his hand. Could he convince them that he was not as bad as they remembered?
"In economic terms, his government was the worst ever in Peruvian history," said Lima economist, Fritz du Bois. "He has become by default the candidate of the business community, the markets and the middle classes. Ollanta Humala's message was so aggressive and hostile to the private sector and hostile in general to the middle class here that they turned to Garcia."
When Mr Humala's weaknesses began to show, Mr Garcia's camp was quick to capitalise on them. Chief among those weaknesses were his own supporters.
One brother is in prison after leading a revolt against President Alejandro Toledo. His mother said that homosexuals should be shot.
Then the president of Venezuela, Hugo Chavez, pledged his support for Mr Humala. But he didn't stop there. He hurled abuse at President Toledo, insulted Lourdes Flores and said that if Mr Garcia became president again, he would only continue robbing the Peruvian people. The Peruvian ambassador to Caracas was recalled.
But many Peruvians, including some of Mr Humala's supporters, were outraged at Mr Chavez's interference and it cost him votes.
The Peruvian economy has done well under President Toledo, helped by high world prices for two of the country's major exports, copper and gold. But 50% of Peruvians live below the poverty line, unemployment is high and thousands leave the country each year in search of work in the United States, Spain and Argentina.
It may be wishful thinking by some, but many Peruvians have become convinced that Alan Garcia can tackle the economy and get to grips with the country's many problems.
Vocal support from Venezuela's Chavez did not help Ollanta Humala
His weaknesses may become his strengths.
Housewife, Margareta Perez said: "OK, he's made mistakes but he's got experience. That's what appeals to me, his experience."
Political columnist, Mirko Lauer, said: "You can't forget we will have Peru's largest party in command and that will help with stability."
With many not sure about Mr Garcia's personal credentials, some still had faith in his APRA party, one of the few political parties with influence on a continent that is seeing many of its traditional party machines disappearing in favour of strong individuals such as Mr Chavez in Venezuela, Alvaro Uribe in Colombia and Evo Morales in Bolivia.
The two candidates in the second round perhaps reflect the deep divides in Peruvian society. Mr Garcia has much of his support in the north of the country. Mr Humala in the south with its strong indigenous communities. The Lima middle classes have reluctantly turned to Mr Garcia as their least bad, their 'menos mal' candidate.
Mr Garcia will have to bridge that divide. And while staying on the right side of his new friends in the business community, he'll also have to ensure that a greater share of Peru's wealth reaches the poor.
They can see from the shanty towns spreading up the hillsides around Lima the shiny shopping centres and plush apartments being built in the affluent parts of the city. They'll only be allowed in there if they're lucky enough to find work as a cleaner or security guard.
Many Peruvians reassure themselves that Alan Garcia simply can't be as bad a president this time as he was last time. They're hoping he'll learn from his mistakes. But he doesn't have much time to prove himself.
The campaign was a long and bitter one and left little in the way of goodwill with which to build the bridges in a divided society.