Dunfermline by-election: Labour's Cara Hilton wins seat from SNP Published duration 25 October 2013

media caption Cara Hilton took the seat after a campaign which centred on local issues

Labour has won the Scottish Parliament by-election in Dunfermline, after beating the SNP by almost 3,000 votes.

The victory represented a gain from the SNP, who took the seat in the 2011 Holyrood election.

The by-election was caused by the resignation of sitting MSP Bill Walker, who was thrown out of the SNP and jailed for domestic abuse.

Cara Hilton, the parliament's newest MSP, said the people of Dunfermline "deserved better".

The SNP won Dunfermline as part of its landslide election win in 2011 with a majority of just 590 votes, but was not able to hold on.

In the end, Labour took the seat with a majority of 2,873 - a 7% swing from the SNP.

The Liberal Democrats came third in the contest, with the Conservatives in fourth place.

Ms Hilton said: "After the disgrace of Bill Walker, Dunfermline deserves better and I will ensure that we will be better - far better than what went before."

And ahead of the SNP administration's independence referendum next year, she added: "We need a Scottish government that will address the needs of Scots, not one that will simply make promises about what will happen after 2016.

"Today Dunfermline has sent a message to Bute House and Alex Salmond: it's time for you to focus on the real priorities of Scots, not your constitutional obsession."

The by-election campaign centred on contentious local issues, including proposed school closures, while the SNP focused on its national policies such as the council tax freeze and the decision to remove the tolls on the nearby Forth Road Bridge.

Despite the result, SNP candidate Shirley-Anne Somerville said she was proud of the campaign she fought.

"We've run a positive campaign trying to support local parents in their schools and I hope we can come together, all of us in the party, to make sure those three schools in the Dunfermline constituency stay open," she said.

The Liberal Democrats saw their vote drop by 8% on the night.

Candidate Susan Leslie said: "I think it has been a victory for women in politics in Scotland that four women stood in this by-election and fought positive campaigns on the issues for Dunfermline."

Scottish Conservative candidate James Reekie - whose party saw a 1% increase in its vote - added: "When the people of Dunfermline are faced with the dilemma of Labour and the SNP, they chose the Conservatives."