Tory Maria Hutchings polled 10,559 votes - more than 1,000 behind Ukip, which snatched huge chunks of the coalition parties' 2010 general election vote share, taking more than 27 per cent of the total.

Conservative Party chairman Grant Shapps tried to play down the significance of the shock result - which influential backbench MP David Davis had warned would mean a "crisis" for his party.

Mr Shapps insisted you "can't read much into by-elections" - seeking to explain the poor showing in what had initially been billed as a two-way fight between the coalition partners as a classic mid-term voter revolt.

But the failure not only to overcome a Lib Dem party engulfed in the Huhne scandal and claims of sexual harassment by a senior party figure but also to outperform Ukip will reignite smouldering backbench dissent.

The Hampshire seat is one of a list of 20 Lib Dem-held constituencies Mr Shapps has said are crucial for the party to win in 2015 if the Prime Minister is to secure an outright majority.

By contrast the result, despite his party's majority being more than halved to 1771, significantly bolsters the authority of the Deputy Prime Minister, who made a string of personal visits to the town.

He has faced intense pressure over his handling of allegations - strongly contested - of sexual harassment against former Lib Dem chief executive Lord Rennard and over dismal national poll ratings since joining the coalition.

In his victory speech Mr Thornton said it was "a great night for the Liberal Democrats nationally, a strong signal of support for Nick Clegg, an affirmation of our role working in the national interest within the coalition and a huge boost to our party's mission in government to build a stronger economy in a fairer society.

Lib Dem president Tim Farron said it represented a "turning point in this parliament" that would "strengthen our hand very much within coalition in the run up to the budget".

And he suggested it left the Lib Dems in "a very strong position to start gaining seats from the Conservatives".

Mr Farron, who declared that the party had "screwed up" its handling of the complaints against Lord Rennard, added: "Without a single doubt at all the party is united behind Nick Clegg. There is no crisis in his leadership."

Ukip leader Nigel Farage said his party appeared to have got more people to back it at polling stations yesterday than any rival but that a well-organised Liberal Democrat campaign to secure postal votes had swung the contest.

"The issues we have surged on in Eastleigh are not going away - they are going to get bigger and bigger. There will be more by-elections and we are getting better and more professional at fighting them," he said.

"This is a massive boost ahead of the local council elections.

"People will say it was a protest vote but who we attracted here were non-voters who had not voted for 20 years - they are not protest votes."

Mr Farage, who had pondered standing himself, told the BBC he would not have done any better than Ms James and joked: "If the Conservatives hadn't split our vote we'd have won, wouldn't we."

She told Sky News: "This will be an absolutely seismic shift in terms of politics and political thinking. The Conservative Party will have to wake up across the country."

Mrs Hutchings, whose 25.4 per cent vote share was 14 points down on what she secured against Mr Huhne in 2010, appeared to be fighting back tears as she thanked opponents for a "clean campaign" and left the count without speaking to the media.

Mr Shapps told the BBC: "In a general election, if people who are looking for a party who can actually go into Downing Street, that is either going to be David Cameron or Ed Miliband," he said.

"If you vote Conservative you know you are voting for a party which has been able to say that net immigration has been cut by a third and a party whereby you will get that referendum on Europe.

"A vote for Ukip when it is a serious general election question would simply put Ed Miliband in Downing Street and there is no way he is going to give you that referendum."

Labour's candidate, satirist and author John O'Farrell, polled 4,088 votes securing only a marginal 0.2 per cent increase on the party's 2010 general election vote share.

It is a disappointing performance for Opposition leader Ed Miliband, who had hailed the by-election as a test for his "One Nation" message.

A Press Association calculation suggests that if the vote share changes were repeated nationwide at a general election, Labour would secure a 60-seat majority, and Ukip would win 17 seats.