Labour today declared a "fightback" was under way after retaining Inverclyde and claimed the Scottish National Party's "bandwagon has ground to a halt".
In a by-election result which will bring some relief to Labour leader Ed Miliband, the party's Iain McKenzie held the seat with a majority of 5,838 - less than half the 14,426 margin gained by his predecessor David Cairns whose death sparked the poll.
A tight contest between the two parties had been forecast in the Labour stronghold after the nationalists swept the board in May's Scottish parliamentary elections.
But speaking after the count Mr McKenzie said: "With a result like this I think we can safely say the SNP bandwagon has ground to a halt. Labour won this election because we listened hard and took nothing for granted.
"This is the start of Labour's fightback and there will be a lot more listening to do over the coming months and years."
The SNP increased its share of the vote on the 2010 general election, and said the 9% swing in its direction had continued the momentum that carried it to a resounding victory in the Holyrood elections.
The SNP's Inverclyde candidate Anne McLaughlin insisted the fight for independence will continue.
She said: "I've been fighting with the SNP for 23 years, I will never give up until we have independence and after we get independence we have a country to sort out."
It was a campaign fought in the shadow of the death of Mr Cairns, a groundbreaking MP whose election sparked a change in the law which had banned former Catholic priests from taking up a seat.
SNP campaign manager Kenneth Gibson said party activists were "absolutely worn out after the Scottish election".
He added: "I would have been absolutely delighted if we won the seat, but unfortunately we didn't win.
"However, I think we had a very good result in that we had the best percentage share that the SNP has ever polled in this constituency since the SNP was formed in 1934."
He said: "This is a serious blow to Labour. In just three weeks the SNP has slashed Labour's lead in their heartlands by over half."
He added: "There will be real questions for Labour's leadership after letting such a safe seat come so close to defeat. The SNP's momentum continues as Labour's woes deepen."
The SNP claimed it was Labour's "negative campaign" that led to its collapse in the Scottish Parliament elections.
But the by-election offered Labour the chance to accuse the SNP of negativity following a controversial Facebook posting by George Adam, MSP for nearby Paisley, who wrote that he would need "jabs" after a visit to Greenock.
Mr McKenzie said: "I get angry when I hear people talk down my community. The people who came here asking for our votes, and then suggested they need jabs to get out of Inverclyde, are beneath contempt."
He added: "I'm proud that my community of Inverclyde has made an important step in Labour's mission to win back the trust of the people both here in Scotland and south of the border.
"Remember, only weeks ago the SNP came within 511 votes of winning here, but tonight the voters of Inverclyde have rejected them - this time giving myself and the Scottish Labour Party not a 500 majority, but over 5,000 of a majority."
Conservative candidate David Wilson claimed a "clear and credible third place" following a huge collapse in the Liberal Democrat vote.Reuse content