LONDON (AP) — London's comic and outspoken mayor Boris Johnson won re-election Friday, triumphing in a closer-than-expected vote to secure a second term and his status as the unvarnished and unpredictable host of the 2012 Olympics
Johnson's victory, in election results confirmed late Friday, was a bright spot on a rough day for his colleagues in Prime Minister David Cameron's governing Conservative Party, who took a drubbing in local elections.
Voters stripped both the Conservatives and Liberal Democrats — the junior partner in Britain's coalition government — of hundreds of local authority seats, punishing the government for biting austerity measures and Britain's stalled economy.
But the Conservatives could take some solace when it was announced that Johnson — known best for his shock of blond hair and sometimes shocking foul-mouthed outbursts — had eked out a win against the opposition Labour Party's Ken Livingstone and earned the privilege of leading London into the global spotlight when the Summer Games begin on July 27.
In his victory speech at City Hall after hours of waiting for results, Johnson did not mention the Conservatives' dismal showing in local elections and instead thanked those who voted for him during the "long and grueling" campaign.
"I want to thank all of you for giving me a new chance and a new mandate to take us forward," Johnson said, pledging to continue "fighting for a good deal for Londoners."
He also somewhat sarcastically described Livingstone — his predecessor as mayor — as one of the "most creative and most original" left-wing politicians he'd seen — a reference to the at-times bitter exchanges between the two candidates.
Livingstone called the defeat the one he will "most regret" in his four-decade career in electoral politics — which appeared to be over late Friday.
"This is my last election," he told City Hall.
Many had expected Johnson, 47, to handily defeat Livingstone, a veteran leftist known for his admiration of Venezuela's Hugo Chavez.
But he won by a tighter margin than expected — 51.5 percent to 48.5 percent — and the drama of the race was heightened by delays in counting ballots. The result was announced just minutes before midnight — more than 24 hours after polls had closed.
Johnson's victory could be bittersweet for Cameron — offering relief from his party's national woes, but cementing the outspoken mayor as a likely future leadership rival.
Cameron's Conservatives took a bruising in votes in the 181 local authorities in England, Wales and Scotland which held polls this year, losing more than 400 seats — including some in the leader's own political district.
Although the results won't put Cameron's leadership in jeopardy, they prompted grassroots Conservatives to urge him to ditch some of his more liberal policies, including the planned introduction of same-sex marriage.
Johnson, who has appealed to traditionalists with messages on tax cuts and looser ties to Europe, is increasingly seen as a plausible national leader — not least for bucking his party's national slump.
"The best thing for Cameron would be to have Boris locked into the London mayoralty for the next four years and out of the way," said Patrick Dunleavy, a political science professor at the London School of Economics.
Cameron also suffered a blow to his legislative hopes, as nine cities — including Manchester, Birmingham and Newscastle-upon-Tyne — voted down plans to have their own directly elected city mayors.
The leader had hoped that new city chiefs, and U.S.-style elected police commissioners, would help deliver power away from Parliament and into the hands of local communities.
Bristol, in southwestern England, was the only city to vote in favor of electing a new mayor.
Like Cameron, Deputy Prime Minister Nick Clegg's Liberal Democrats — the junior partner in Britain's coalition government — suffered a collapse, losing 336 councilors. That pushed their total number of local councilors below 3,000 for the first time since the party formed in 1988.
Main opposition Labour Party leader Ed Miliband toasted his own party's revival after its ousting from national office in the 2010 national election. It won control of 32 more local authorities and claimed 823 new council seats.
"We are a party winning back people's trust," Miliband said. "People are hurting. People are suffering from this recession, people are suffering from a government that raises taxes for them and cuts taxes for millionaires."
Cameron insisted his poll battering was to be expected at the midpoint before a 2015 national election, and with his government carrying out grueling economic repairs following the global economic crisis.
"These are difficult times and there aren't easy answers," Cameron acknowledged.
Elsewhere, the United Kingdom Independence Party — which advocates a British withdrawal from the European Union — made advances. The far-right British National Party saw its vote wiped out, losing all six council seats it held in the areas contesting elections.
In Scotland, Alex Salmond's separatist Scottish National Party made local gains before an expected 2014 referendum on independence but win control of Glasgow's council, a key target.
Associated Press writer Bob Barr contributed to this story.