Boris Johnson (R) looks on as his main opponent Ken Livingstone speaks after the election results are announced.

Story highlights

Conservative Boris Johnson wins second term as London's mayor

He narrowly beat former mayor and Labour Party candidate Ken LIvingstone

The post is largely ceremonial, though the Mayor controls a $23 billion budget

London will host the 2012 Olympic games in less than three months

CNN  — 

Boris Johnson was re-elected as Mayor of London Friday after a narrow victory over Ken Livingstone, who held the post until 2008.

Conservative Party incumbent Johnson, 47, polled 1,054,811 votes compared to his long-time Labour Party rival’s 992,273 votes.

Neither candidate won enough votes in the first round of voting to secure victory, meaning second preference choices had to be counted.

With all to play for ahead of this summer’s Olympic games in the city, the two maverick politicians embarked on an election campaign that showed there was no love lost between them.

London mayoral election: Battle of the buses

At one point during the campaign, as both rivals accused each other of avoiding paying the full rate of income tax, Johnson – who was born in New York to British parents – accused Livingstone of being a “f***ing liar.”

Livingstone, 66, was instrumental in helping win the bid to stage the Games in 2005 during his second term in office, though both candidates claimed credit for the massive regeneration of east London around the Olympic site. As the head of the Greater London Council (GLC) in the 1980s, Livingstone earned the moniker “Red Ken” for standing up to Conservative Prime Minister Margaret Thatcher on a number of issues.

Why mayoral elections matter so much to women

But it was the scruffy-haired Old Etonian, Johnson, who ended Livingstone’s reign as mayor in 2008, after a surprise win. Critics believed the outspoken, gaffe-prone ex-journalist was not serious enough for the post. However a number of high-profile initiatives, including a London-wide public cycle hire scheme and a plan for a new railway link across the city, soon won him praise.

Speaking after Friday’s victory, Johnson vowed to continue “fighting for a good deal for Londoners” from central government as he thanked voters for giving him a “new chance,” Britain’s Press Association reported.

Livingstone, meanwhile, immediately announced his retirement from politics. “This is my last election,” he told supporters at London’s City Hall, in quotes carried by PA.

“Forty-one years ago almost to the day, I won my first election on a manifesto promising to build good council housing and introduce a free bus pass for pensioners. Now I’ve lived long enough to get one myself. I didn’t think I necessarily would at the time.”

While the job of mayor is largely ceremonial, whoever holds it does have control of a £14 billion ($23 billion) budget to run the city’s vast transport system and emergency services as well as promote business.

Elsewhere, the Labour Party made big gains over Prime Minister David Cameron’s Conservatives in local elections held Thursday.

Labour have gained 825 local council seats, while the Conservatives have lost 405 and the Liberal Democrats 336, according to BBC projections.

This makes the London mayoral election result one bright spot in a gloomy overall picture for the Conservatives, who are feeling the effect of voters’ dissatisfaction over measures to tackle the country’s large deficit.