The Liberal Democrats held off a late Ukip surge to win the Eastleigh by-election, but David Cameron was dealt a serious blow as the Conservatives were pushed into third place.
Nick Clegg said his party was "on track" for the 2015 general election after local councillor Mike Thornton held on to the seat vacated by disgraced ex-Cabinet minister Chris Huhne.
Mr Clegg said the message of the Eastleigh by-election was that "we can be a party of government and still win". He told activists in Eastleigh: "We held our nerve, we stood our ground... We overcame the odds and won a stunning victory."
Mr Thornton won with 13,342 votes, a majority of 1,771 over the UK Independence Party's Diane James, who said beating the Tories was a "humongous" shock that represented a "seismic shift" in UK politics.
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% 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 previously 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.
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".
Mr Farage said success in the polls was not the result of a protest vote, but because his party connects with people who want it to speak for them. He told ITV's Daybreak: "If people who have not voted for 20 or 30 years go out to the ballot box in a by-election and vote, that by definition cannot be a protest vote. It is people saying, 'Ukip, speak for me', and they are re-engaging with the democratic process. That is a long, long way away from a protest vote."