The Liberal Democrats have kept control of Eastleigh after a terrible night for the Conservatives which saw them fall to third place behind Ukip.
The eurosceptic party enjoyed its most significant victory to date with 11,571 votes. The Liberal Democrats won with 13,342 votes.
The Tories took just 10,559 votes, down 14% on their 2010 performance. Labour came fourth with 4,088 votes.
Conservative candidate Maria Hutchings appeared on the verge of tears during her post-results speech and then left the counting hall without speaking to any press.
"Tonight is a great night for the Lib Dems nationally - a strong symbol of support for Nick Clegg, an affirmation of our role and a huge boost to our party's mission in government," Lib Dem candidate Mike Thornton said.
"I hope this result goes to show those who have written us off as a party that the Liberal Democrats can do it, we have done it and we will do it again."
The Liberal Democrat result was actually very poor. Their majority of 1,771 is a 2,093 reduction on their 2010 performance – broadly in line with their decline in national opinion polls.
Their winning vote share of 32% is the lowest in a post-war by-election. The nearest competitor is Roy Jenkins' win in Glasgow Hillhead with just 33.4% in 1982.
The result will nevertheless be an overwhelming relief for Nick Clegg, who can tell his party it can survive poor nationwide polling results with hard-fought local campaigns.
The victory is particularly meaningful given the by-election was triggered by the unprecedented spectacle of a Lib Dem MP stepping down due to a criminal conviction and amid the continuing fallout from the Rennard scandal.
The main loser of the evening was David Cameron, whose authority with his already rebellious backbenchers will be further dented by a poor performance in one of his party's key target seats.
The prospect of a Tory majority in 2015 is now increasingly unlikely, as the party's entire strategy of taking 20 seats off the Lib Dems appears fraught with difficulties.
Ukip will be jubilant after an impressive and well organised campaign by Diane James. The party now appears to be sucking up protest votes from across the political spectrum.
But the biggest danger the party poses is toward the Tories after the eurosceptic party finally appeared to be splitting the right-wing vote.
James' performance also suggests Ukip is no longer a one-man-band centred around Nigel Farage.
"I may have come second but you, the people of Eastleigh, have delivered an almighty political shock," she said after the vote.
Labour had a dreadful night, only improving its share of the vote by 0.2%, leading many commentators to question whether Ed Miliband's 'one nation' message is gaining any traction in the south.
Turnout was a healthy 52.8% - down from 69% in the 2010 general election.