General election 2017: Labour celebrates after capital result
Labour's Ian Murray has increased his majority to more than 15,000 to give him the safest seat in Scotland.
Mr Murray, who was elected as Labour's only Scottish MP in 2015, held the Edinburgh South seat with 26,269 votes. The SNP came second with 10,755 votes.
His majority increased significantly from 2,637 two years ago to 15,514.
Across the capital, the SNP held three seats - Edinburgh South West, North and Leith and Edinburgh East, while the Lib Dems gained Edinburgh West.
In his victory speech at the Meadowbank count in the city, Mr Murray told his supporters: "I stood here two years ago bemoaning the loss of my colleagues but tonight the Scottish Labour Party is back.
- Election 2017: Scottish results
- Election 2017: At-a-glance
- May under pressure after election losses
- Kuenssberg: Can Theresa May stay as PM?
"Nobody wanted this general election. Theresa May called this election to get rid of scrutiny in parliament for the hard Brexit she wanted to deliver.
"Well the people of this country, the people of Scotland, have said tonight that we do not give the prime minister a blank cheque for a hard Tory Brexit."
Mr Murray also told Nicola Sturgeon that his party's result was a verdict on SNP calls for another vote on independence.
He said: "And to the first minister, we said at the start of this campaign that Scotland didn't want a second independence referendum.
"The people of Edinburgh South have hammered the final nail in that coffin tonight."
Tommy Sheppard won Edinburgh East with 18,509 votes, beating Labour's Patsy King into second place on 15,084.
"The overwhelming story of tonight is that this is the Conservative Party snatching defeat from the jaws of victory," Mr Sheppard said.
"There is one clear victor in the general election in Scotland, one party that is on course to win more seats than all other parties put together, and that party is the Scottish National Party.
"Ruth Davidson sought a mandate in this election to try to prevent the people of Scotland having a choice about their future and she has overwhelmingly been rejected by the Scottish electorate."
Nationalist Deidre Brock held her constituency Edinburgh North and Leith with 19,243 votes, despite a strong challenge from Labour's Gordon Munro on 17,618.
The SNP's Joanna Cherry also kept her Edinburgh South West seat, with 17,575 votes to the Conservative Miles Briggs on 16,478.
But Liberal Democrat Christine Jardine took Edinburgh West with 18,108 votes to 15,120 for the SNP's Toni Giugliano.
The seat was won by Michelle Thomson in 2015, who later resigned the SNP whip after allegations relating to property transactions.
Ms Jardine said: "We've been away for a wee while but the Scottish Liberal Democrats are back."
Across the Forth in Fife, the SNP held the area's North East seat with just two votes.
It was the final Scottish seat to declare in the UK general election, after a third recount.
The SNP's Stephen Gethins won 13,743 votes compared with Janet Riches of the Scottish Liberal Democrats who polled 13,741.
It is the joint-third narrowest victory in UK general election history and the closest since the Lib Dem's Mark Oaten won Winchester by two in 1997.
Mr Gethins saw his majority cut from 4,344 in 2015.
Labour's Lesley Laird took Kirkcaldy and Cowdenbeath from the SNP with 17,016 votes, while the SNP's Peter Grant held Glenrothes with a much reduced majority over Labour's Altany Craik.
The SNP also held Dunfermline and West Fife, with Douglas Chapman securing 18,121 votes compared with Labour's Cara Hilton on 17,277.