David Cameron said he was "delighted" by Boris Johnson's mayoral victory and vowed the pair would work together for the good of London.
The Prime Minister praised Mr Johnson for running a "very strong" campaign and said he had enjoyed backing his bid for re-election.
Speaking at City Hall, Cameron said "I think it was a very strong campaign by Boris. It was based on his record, on the excellent things he has done out there and I am delighted to congratulate him.
"It was a campaign the whole Conservative party got behind.
"I enjoyed campaigning for Boris but now what matters is working together for the good of London, as PM, as Mayor, and that is exactly what we are going to do."
Standing by the PM's side today, the mayor said he hopes "very much" to continue working with the Government to secure investment for London.
He added: "I think people were listening to what we had to say about taxes, getting rid of all sorts of unnecessary expenditure, putting it where people want to see it.
"It was a very hard-fought long campaign.
"I am grateful to the Conservative Party. They did turn out in large numbers to help me but I think we were able to reach people across the city with a message that resonated with them in tough times."
He added: "I hope very much to continue working with the Government to get the investment that London needs."
Despite Cameron's praise, the Mayor's victory could not mask a disappointing day for the Tory Party, which suffered a significant drubbing nationally at the polls.
On Friday, some Tory right-wingers accused Cameron of betraying true conservatism, with MP Douglas Carswell blaming the poor electoral results on "wind turbine Toryism".
Johnson's victory will increase speculation that the mayor will set his sights on Downing Street after his four-year tenure at City Hall is completed. Tensions between the mayor and the prime minister have been rumoured, with Johnson a possible challenger to Cameron for leadership of the party.
However, when asked if he would attempt to be re-elected to parliament in two or three year's time, allowing him to position himself as a future Tory leader, Johnson told Nick Ferrari on LBC 97.3: "I'm going to say this categorically that the answer to that is no, I don't want to do that. I want to discharge my mandate and my duty."
"London has an amazing future and I’d be crazy not to focus on that."
Johnson's father Stanley refused to rule out the possibility of his son as future leader saying: "Who knows?."
Asked by the BBC why Boris bucked the national trend he said: "Because he had the charisma and because people believe he is a man that says what he means and he does what he says and that's something that counts."
To enthusiastic applause from party members Johnson signed the declaration of office on Saturday afternoon.
He told the group the election had given him a mandate to go forward with the controversial automation of the Tube.
Watched by Scotland Yard boss Bernard Hogan-Howe he added the result also gave him a mandate to keep police numbers high.
He promised to "work his socks off" and stand up for London in Whitehall.
Johnson signed the declaration of office at City Hall
Johnson was re-elected as Mayor of London in a surprisingly narrow victory that saw him beat rival Ken Livingstone in the early hours of Saturday morning.
The Conservative polled 1,054,811 to the Labour candidate's 992,273 following a deeply personal and bitter campaign battle that saw the two men clash furiously in public and in private.
Johnson vowed to continue "fighting for a good deal for Londoners" from government as he thanked voters for giving him a "new chance".
Early results in the contest also suggested the incumbent was significantly in the lead and even senior Labour figures conceded the Tory was poised to win. But later count declarations saw the gap reduce, fuelling speculation Mr Johnson's victory was not the done deal that had been tipped.
No candidate won enough votes in the first round to secure victory, meaning second preferences had to be counted.
Labour secured eight of the London Assembly's 14 first-past-the-post constituencies, gaining two from the Tories, which left them with six.
Full coverage of Friday's local and mayoral elections:
Liberal Democrat Brian Paddick was pushed into a humiliating fourth place after polling 91,774 votes, compared to the 98,913 secured by the Greens' Jenny Jones.
Political newcomer, Independent Siobhan Benita, took fifth with 83,914.
Ukip's Lawrence James Webb polled 43,274 while the British National Party's Carlos Cortiglia came last with 28,751.
Counting, which is carried out electronically, was dogged by delays, pushing back the result back significantly on original predictions that it would be announced in the early evening.
They included a power cut at Alexandra Palace as well as the reprocessing of two mislaid batches of ballot papers in the Brent and Harrow constituency.
In his victory speech Johnson admitted it had been a "long and gruelling" campaign.
The Conservative went on to take a swipe at his Labour rival - during the campaign he had rowed with him in a lift and called him a f****** liar - saying last time round he had said complimentary things about Mr Livingstone adding: "Fat lot of good it did me."
He added sarcastically: "Of all the left-wing politicians I can think of your long period in office... you have been the most creative and the most original.
OPINION: Scroll down to leave your comments
"And, if only you will promise not to stand again, I much look forward to having that non-taxpayer funded drink that we have so far not managed to fit into our diaries."
He pledged to make sure Londoners, especially young people in the city, were "ready to take the jobs" that are being created.
Johnson said he wanted to thank those who voted for him, those who did not and those who thought about it.
"I want to thank all of you for giving me a new chance and a new mandate to take us forward."
Livingstone dramatically announced his retirement from electoral politics in his speech accepting defeat immediately after the result was declared.
"This is my last election," he told fellow-candidates and supporters at City Hall. "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.
"And since then, I've won 11 more elections and lost three. But the one I most regret losing is this. This is the defeat I most regret, because these are the worst times for 80 years, and Londoners needed a mayor to get them through this very difficult period by cutting fares, by cutting energy prices and putting people back to work building good council homes.
"I am sincerely sorry to those Londoners who desperately wanted us to win that I failed to do that and they will continue to bear the pain of this recession without any help from here in City Hall."
Livingstone suggested that Johnson may have sealed the succession as next Conservative leader with his victory today.
Joking that the mayoral result might have spoiled David Cameron's supper, the veteran Labour candidate said: "The real story tonight is that under Ed Miliband we have won in every part of the country.
Ken Livingstone announced his retirement from electoral politics
"I want to congratulate Boris on his personal victory. Whilst Cameron and Osborne are dragging the Tory Party down to defeat in the rest of Britain, not only have you won another term, but I suspect this result has settled the question of the next Tory leadership election."
Livingstone hailed Jenny Jones' third place as a "huge breakthrough for the Green Party", and said that Lib Dem Brian Paddick's fourth place was not his fault, adding: "I suspect that nice Mr Clegg."
Thanking supporters, activists and Miliband for their help with a "gruelling" campaign, he said: "I am truly sorry I couldn't pull this victory off, but I am incredibly proud of our team and its incredibly hard work."
Livingstone said he wondered whether the "negativity and smears" of the London campaign had influenced cities around England which rejected directly-elected mayors in referendums.
And he gave a warning for the future unless Labour wins back power in 2015: "Today's teenagers are the first generation of English men and women who face a worse prospect than their parents.
"This is because the aggressive free-market agenda set by the Tory Party 30 years ago has failed to deliver the sound economy they promised. Osborne pushing us back into a double-dip recession merely confirms it."
He added: "London is the most amazing city but our children must be able to find homes and jobs in it, as they must in the rest of Britain.
"The gains that Labour has made today are a big stride towards achieving that under Ed Miliband at the next general election."
Len Duvall, the leader of the Labour group on the London Assembly, said he was "disappointed" at Mr Livingstone's defeat.
He added: "However, Labour has made significant gains on the London Assembly, unseating some of Boris' key lieutenants and came close to removing two more.
"The Labour group on the London Assembly will scrutinise the Mayor and highlight his failing policies and his total lack of vision for our great city. If he thinks he can coast along for the next four years he is in for a rude awakening."
Conservative Party co-chairman Baroness Warsi said: "This is an historic result. The greatest city in the world has re-elected a Conservative mayor.
"Boris Johnson's re-election is a testament to the way he has connected with Londoners; to his modern, inclusive approach; and his clear vision for a safer, greener, more prosperous London.
"In the coming weeks and months the eyes of the world will be upon the capital, as we host the Olympic and Paralympic Games and we are at the centre of celebrations for the Queen's Diamond Jubilee. In Boris, London has a mayor with the authority, presence and charisma to represent this great city on the world stage.
"Boris, and the countless volunteers who gave their time and support to this campaign, can be immensely proud of what has been achieved.
"This is a victory for the Conservatives, a victory for a mayor who has devoted the last four years of his life to this city and, above all, a victory for London."
Suggested For You
SUBSCRIBE AND FOLLOW
Get top stories and blog posts emailed to me each day. Newsletters may offer personalized content or advertisements.Learn more