* Coalition parties fare badly in local council elections
* Conservative maverick Boris Johnson wins London
* Labour makes big gains, UKIP sees rising support
* Cameron comes under pressure from right-wingers
By Peter Griffiths and Tim Castle
LONDON, May 4 (Reuters) - Boris Johnson dodged a humiliating n ationwide d efeat for Prime Minister David Cameron by winning London in local elections that saw voters angry at Britain's economic woes flock to opp osition Lab our and a ri ght-wing anti -European fringe party.
M averick mayor Johnson 's silver-lining win in London was the only good news for Cameron whom local media said had been given a bloody nose by voters upset at sp ending cuts and Bri tain's return to recession.
E ven Johnson, who as one of the most popular politicians in Cameron's own party is tipped as a possible future prime minister, saw his majority slashed, claiming victory only after a lengthy count that had put him head to head with his rival, Labour candidate Ken Livingstone.
"I will continue to fight for a good deal for Londoners, a good deal from the government that will help us deliver prosperity for everybody in this city," Jo hnson, famous for h is ru f fled fair hair, sai d after the vote count at London's City Hall, a rounded glass building on the Thames.
Johnson failed to mention the wider Conservative defeat, but his challenger, Livingstone , said that the victory could put Johnson on course to one day lead the Conservative party.
With results declared in all 181 councils being contested across the country, Labour had gained 823 new councillors while the Conservatives had lost 405 and their Liberal Democrat coalition partners were down by 336.
After preaching economic prudence, Cameron's coalition government was damaged by a return to recession and weeks of blunders th at m ade ministers appear out of touch with voters struggling with hig h unemployment, pri ce rises and low wages.
Cameron apologised to Conservative candidate s who lost their jobs, blaming the defeat on the tough decisions he had been forced to make to reduce Britain's debt mountain and mend th e $2 . 5 trillion eco nomy.
"There aren't easy answers," said Cameron, whose party lost seats to Labour in the rural constituency he represents in parliament.
Labour said the results were a wake-up call for the government to soften its flagship deficit-cutting agenda.
"People are hurting, people are suffering from the recession, people are suffering from a government that has raised taxes for them and cut taxes for millionaires," said Ed Miliband, leader of centre-left Labour.
For Miliband, who has been under constant fire since he took over the Labour Party in 2010, the vote was a rare victory - with the exception of London - though he was pelted with an egg during a celebratory walk through Southampton.
The government's drubbing increased pressure on Cameron from within his own party to shift his electoral strategy t o the right, a step Cameron's supporters say would be electoral sui cide an d sour his relations with his coalition partners, the cent re-left Libe ral Democrats.
" David C ameron is fighting to run a government with one hand tied behind his back because we are attached to wishy-washy Li b erals and of course what Li b erals are good for is o pposition but they are absolutely useless in government," C o nservative lawm aker Pete r Bone tol d the BBC.
Derided as "arrogant posh boys who don't know the price of milk" by a Conservative rebel, Cameron and his finance minister George Osborne have struggled with a view that they are out of touch. This was reinforced by a row about the so-called "pasty tax", a sales-tax rise that pushed up the price of pasties, a cheap and popular snack.
Foreign Secretary William Hague sought to play down the scale of the Conservatives' defeat, saying it was "perfectly common" for governments to suffer losses at mid-term local elections. A national vote will be held in 2015.
UKIP, which stands for UK Independence Party, was contesting only a fraction of the total seats up for grabs but where it did field candidates, it averaged a record 14 percent of the vote.
This translated into just nine councillors because UKIP's support is geographically scattered, which makes it hard for the party to win any individual ward.
However, UKIP's surge was a clear threat to the Conservatives, who need to increase their popular support before the next national election.
"What they're scared of is that this trickle of support that has come to UKIP could turn into a flood," UKIP leader Nigel Farage told Reuters on Friday.
Philip Davies, a Conservative member of parliament, told Reuters there was no doubt that UKIP was taking votes from the Conservatives and that it was "a massive threat".
"They will undoubtedly stop us from winning seats that we would otherwise win (in 2015), and given how difficult it is for us to win an overall majority, every seat counts," he said.
At the last national parliamentary election, in 2010, the Conservatives fell short of an overall majority even though Labour were unpopular after 13 years in power. Cameron was forced to form an uneasy coalition with the Liberal Democrats.
Vociferous right-wingers within the Conservative Party have always maintained that Cameron should have done more to appeal to the party's traditional supporters by attacking the European Union and talking tough on crime and immigration.
"So far he's tended to treat his party like a general, a field-marshal. But he has to realise it's not his party and listen to other voices in the party," influential online Conservative activist Tim Montgomerie told Reuters.
"Until he shows he's an electoral success, he won't command loyalty. The Conservative Party is an election-winning machine and right now it's a machine that's not working."
Cameron's cherished policy of strengthening local democracy by introducing elected mayors also suffered a setback. Vo ters in ei ght cities voted against having a directly elected mayor, with only Bristol voting in favour.
The picture was equally bleak for the Liberal Democrats, whose support has collapsed since they went into government. The local election results in England were the worst in their history.
In one area of Edinburgh, the Lib eral Dem ocrat s won fewer votes than a climate activist wearing a penguin suit calling himself Professor Pongoo.
Labour, which had struggled to capitalise on the coalition's problems, captured 38 percent of the national vote versus 31 percent for the Conservatives and 16 percent for the Lib Dems. Voters tur nout was low at just 32 percent.