The battle to be mayor of Lima, finally won by Susana Villaran, may have been the tightest electoral race in Peru's history. It was certainly one of the most drawn-out.
Electoral officials took more than three weeks to recount 8,384 ballots that were challenged over technical errors such as missing fingerprints and signatures on tally sheets.
Exasperated Lima residents, who cast their votes on 3 October, took to the streets in protest just a day before conservative candidate Lourdes Flores conceded defeat to Ms Villaran.
Ms Villaran, the candidate for a leftist movement known as Fuerza Social (Social Force), becomes the first elected female mayor of the Peruvian capital since it was founded in 1532.
The former teacher and human rights activist will also be the first leftist mayor of Lima since 1983 when she takes office in January.
But despite her clear popularity among a section of the electorate, Ms Villaran's leftist credentials caused some dismay among the business elite and powerful conservative sectors of the establishment.
Ms Flores, the candidate for the right-wing Partido Popular Cristiano, tapped into fears about the radical left to rapidly gain on Ms Villaran's 12% lead in the opinion polls in the last week of campaigning.
"I haven't seen such a surprising election in the last 30 years," said Fernando Tuesta, political scientist and pollster at Lima's La Catolica University.
"Susana Villaran's lead appeared to be unassailable and then Lourdes Flores caught up within 24 hours."
"She managed to summon up the nightmare of terror. For the Peruvians who lived it and Peruvians who inherited its legacy," he said referring to Peru's internal conflict with the communist Shining Path rebel group in the 1980s and 90s in which nearly 70,000 people were killed.
Sections of the media joined in. On election day, one newspaper's headline read: "Between Terrorism and the Future", with a picture of the two candidates.
Unlike other Latin American countries, the moderate left has made little headway in Peru in recent years.
Peru's current president, Alan Garcia, now a clear fan of the free market, is a former leftist whose first government in the late 1980s ended with massive hyperinflation.
But Ms Villaran's message of social inclusion and her background in women's rights gave her strong appeal among the capital's poorer residents, who feel Peru's economic boom has passed them by.
"The vote for Susana in Lima is a personal vote for her, it's not ideological, " says Alfredo Torres, director of the polling company Ipsos-Apoyo.
Ms Villaran favours gay marriage and the decriminalisation of abortion, both deeply controversial topics in Peru. Her stance could have lost her votes.
Nonetheless, her campaign slogan "hope will conquer fear" finally won through, albeit by the smallest of margins.
"There's a demonisation of the left which represents the interests of groups in power," she told the BBC before securing her victory.
"But we live in different times now and the use of fear to manipulate people so that the authoritarian option continues to control our society is coming to an end. That's a sign of democratic renewal."
Her victory appears to be part of a broader trend in Peru to reject the traditional political parties, particularly the governing APRA party, which did not win a single major provincial city during the municipal elections.
Opinion polls for the presidential election in April 2011 give the party of President Garcia, who himself cannot stand again, less than 5% of the vote and it has yet to nominate a candidate.
"People want new faces, they're yearning for novelty, be the candidate left, right or centre. There is not yet an ideological stance," says political commentator Mirko Lauer.
"I think Susana's win is part of a new phenomenon which we'll see more of in the elections 2011.
"Rather than being a comeback for the left, it's more a sign that people are fed up with traditional politics and the same political faces who run in three, four or five elections."
The rejection of traditional parties was also evident in elections for governor, which saw most of Peru's 24 regions won by independents campaigning on regional issues.
"They just want a piece of the action but they know they won't get that within the main parties so they set up their own lemonade stand and negotiate," says Mirko Lauer.
"It is Peruvian enterprise - we've entered the era of franchise and the independent parties are franchising out to the bigger parties."
As candidates, both Ms Villaran and Ms Flores pledged to clamp down on corruption and boost efficiency if they were voted into office.
It seems that Ms Villaran's charisma clinched her victory, but only just.