A Conservative lawmaker with a knack for offensive remarks ousted the left-wing mayor of London in an upset that capped the ruling Labour Party's worst local election showing in four decades.

Results released early Saturday showed Boris Johnson defeating Ken Livingstone in Labour's first test at the polls since then-Prime Minister Tony Blair handed the reins last year to Gordon Brown, who has since been dogged by accusations of indecision and incompetence.

Voters also picked opposition candidates in more than 300 municipal council races, prompting Brown to humbly pledge to heed the scathing verdict.

Conservative leader David Cameron said his party's strong gains represented a key moment on the path to ousting Brown at the next national election, to be held before mid-2010.

"Three years ago the idea that the Conservatives would win London and build up a 20-point lead across the county would have been literally unthinkable," Cameron said.

"I do hope that it does show that the Conservatives have changed into a party that can again be trusted," Johnson said, shortly after the result was announced to cheers from raucous supporters. "Let's get cracking tomorrow and let's have a drink tonight."

Johnson, a former magazine editor, offered lavish praise for his rivals in the race and paid tribute to Livingstone's role in guiding London through the 2005 transit network bombings.

Livingstone — a staunch leftist who courted Venezuela's Hugo Chavez and faced off with the U.S. Embassy for unpaid congestion charges — said the blame for his defeat must rest at his door, not Brown's.

"I accept that responsibility and I regret that I couldn't take you to victory," the veteran politician said, looking pale and crestfallen. He leaves office immediately.

Johnson took 1,168,738 votes to Livingstone's 1,028,966 in a contest that hinged on a second round of voting.

Voters are asked to pick a first, then second choice as mayor — Johnson didn't win the required 50 percent initially, but triumphed when second preferences from eight minor candidates, eliminated after the first round, were added to the totals.

Uncombed and often awkward, Johnson is known both his wit and for remarks that are have offended minority communities and others.

He labeled members of the Commonwealth "piccaninnies" — a derogatory term for black people, referred to Africans as having "watermelon smiles," and likened his party's internal conflicts "to Papua New Guinea-style orgies of cannibalism and chief-killing."

Johnson's scorn has also been directed at gay marriage, which became legal in Britain in 2005. In his book "Friends, Voters, Countrymen," he said that if homosexuals could marry then why not "three men, as well as two men; or indeed three men and a dog."

Ex-party leader Michael Howard ordered Johnson to visit the northern city of Liverpool in 2004 to apologize after he wrote an editorial accusing the city's people of "wallowing" in victimhood after Liverpudlian Ken Bigley was taken hostage in Iraq and beheaded.

Johnson has cultivated a befuddled, rumpled image and was often seen clumsily pedaling his bicycle to Parliament.

His campaign billboards featured silhouettes of his iconic poses — scratching his unruly thatch of blond hair, ambling along a road with hands stuffed in wrinkled pockets, gesticulating wildly to make a debating point.

His first key test is likely to hinge on how he handles relations with China. As mayor, he will be expected to attend at least part of the Beijing Olympics — and his party will hope he is able to avoid offending the hosts.

"Chinese cultural influence is virtually nil, and unlikely to increase," Johnson wrote in one of his several books — on subjects ranging from sports cars to Ancient Rome.

Johnson said it is likely "there will be the odd ill-chosen expression" in his future.

Results from the 159 local councils which held ballots in England and Wales on Thursday showed the Conservatives gaining 260 seats with Labour losing 333. The Liberal Democrats gained 34 seats.

Most results were announced Friday, but a high turnout in London — where around 5.5million cast ballots — meant the count there continued until early Saturday.

The British Broadcasting Corp. projected the Conservatives would take 44 percent of the vote in England and Wales, putting it 20 points ahead of Labour. Brown's party was a point behind the Liberal Democrats, usually the country's third-largest party, according to the BBC.

Brown was credited with overseeing Britain's longest stretch of postwar prosperity and enjoyed a strong start as prime minister when he took the post in June.He claimed to represent substance after the slick Blair years, but a brief honeymoon with voters ended abruptly when he anguished over, and then ruled out, a snap national election in October.

Since then, grumbles over rising food and fuel prices, tax changes that have hit blue-collar workers and the costly nationalization of mortgage lender Northern Rock have conspired to send poll ratings for his Labour Party to a 20-year low.

One Labour peer, Lord Desai, recently quipped that Brown's true role was to show his party how much they missed Blair.