Votes are being counted in the Rochester and Strood by-election, with Ukip confident of taking a second seat from the Tories, but perhaps by a narrower-than-predicted margin. Mark Reckless appeared poised to join fellow defector Douglas Carswell by returning to the Commons to represent the seat he won as a Tory in 2010 under the Eurosceptic party's banner.
Counting gets under way for the Rochester and Strood constituency by-election held at Medway Park, Gillingham, Kent
Ukip leader Nigel Farage predicted that the result would be tighter than the significant margins suggested by opinion polls and a Cabinet minister said the Tory vote was "holding up well". A narrow loss may ease nerves in the Conservative high command that other Eurosceptic waverers in the ranks will jump ship and join them, with one right-wing backbencher ruling it out and another saying it would be "insane".
And David Cameron was handed a boost after newspaper headlines were grabbed not by his expected bloody nose at the hands of Nigel Farage, but by a senior Labour MP quitting the shadow cabinet. Shadow attorney general Emily Thornberry stepped down after apologising for tweeting what was criticised as a "snobbish" picture of a house in the Kent constituency draped with England flags.
Tory Work and Pensions Secretary Iain Duncan Smith accused her of "sneering at the electorate of Rochester" and said it showed Labour "doesn't even respect the people they expect to vote for them now". Defeat - however narrow - would be a particularly wounding blow for the Prime Minister, who has personally spearheaded a concerted fight for a seat his party had claimed just weeks ago it had a good chance of holding.
And Mr Farage, whose party's dramatic surge has undermined Mr Cameron's chances of returning to Downing Street in next year's general election, said a Ukip victory would put the result of the 2015 poll "up in the air". "I feel our vote is solid. I think we are going to win but I think it's maybe closer than people think," he said.
Votes are counted at Medway Park in Gillingham as as the polls close on the Rochester and Strood by-election
Mr Duncan Smith declined to accept defeat despite Tory sources suggesting the party had no hope of winning, insisting he thought the Conservative vote was "holding up pretty well actually". "We have fought it. We want to win it. We don't know what the result is going to be. We will wait and see what happens. I wouldn't count chickens before they have definitely hatched," he told Sky News.
He insisted the vote was "not about the general election", which would be a fight between the Conservatives and Labour. After a campaign dominated by immigration, Mr Reckless is the strong favourite to regain the constituency in Kent, just weeks after the previously safe Tory seat of Clacton was won for Ukip by Mr Carswell.
Some polls have suggested that former Conservative voters planning to support Ukip in the by-election will return to them in the general election in May. Labour, expected to come in a distant third, ran a low-key campaign and sought to play down the significance of the by-election for its general election prospects, pointing out it did not need to seat to secure a Commons majority.
But it found itself thrust embarrassingly into the spotlight over Ms Thornberry's picture. The Islington South and Finsbury MP posted the image of the modern terraced house with three red and white Cross of St George flags and a white van in the drive along with the message "Image from Rochester".
After a social media and political backlash, she apologised after being given a dressing-down by leader Ed Miliband and Labour later announced that she had resigned as shadow attorney general. Eurosceptic Tory backbencher Philip Davies denied that he was planning to defect.
The Shipley MP told BBC2's Newsnight: "I agree with Nigel Farage on nearly everything. It's probably fair to say I agree with him on more issues than I agree with David Cameron." But asked if he was tempted to defect to Ukip, Mr Davies said: "Absolutely not, because I'm a Conservative. Any particular leader isn't the party itself, it just happens to be whoever is the leader.
"The only way we are going to leave the EU is if we have a referendum. The only way we are going to have a referendum is if we have a Conservative government."
Right-wing Conservative MP Stewart Jackson said: "Any Tory MP who defects to Ukip on the basis of the result in Rochester and Strood - whatever it is - would frankly be completely insane."
Turnout in the by-election was 50.67%, or 40,113 votes, acting returning officer Neil Davies said.