BEN Macpherson secured an SNP victory in Edinburgh Northern and Leith, the only seat in the city which Labour managed to hold onto in 2011.
Mr Macpherson had a majority of almost 7000.
He said the SNP had won by taking a consistently positive message to every part of the constituency.
But he also paid tribute to the former MP, Labour’s Malcolm Chisholm, who stood down at the election.
Mr Macpherson said: “He believed in social justice, helping other people and a more constructive approach to politics – and so do I.
“With new energy and new ideas I will work tirelessly to build on the high standard of representation Malcolm Chisholm has set.
“Elections can be divisive, but we must always remember there is a shared purpose and hope.
“We all want a fairer and more prosperous Scotland.”
Defeated Labour candidate Lesley Hinds said once the equivalent Westminster seat had been lost at last year’s general election she knew it would be a difficult task.
“I’m disappointed we have not been able to keep the seat for Labour. But Labour will be back,” she said.
In Edinburgh Eastern, Kezia Dugdale lost out to the SNP’s Ash Denham.
Ms Denham thanked voters for “putting their trust once again in the SNP and our positive vision for Scotland.”
She said: “I will work hard to repay that trust.”
The SNP’s Gordon Macdonald was re-elected in Edinburgh Pentlands with a comfortable 2000-plus majority over the Tories.