Labour has gained Midlothian from the SNP with a majority of 885 votes.
Danielle Rowley came out on top with 16,458 votes (36.4 per cent), beating the SNP’s Owen Thompson into second with place with 15,573 votes (34.4 per cent).
With an overall turnout of 66.3 per cent, the declaration was made at 2.23am.
Tory Chris Donnelly came in third with 11,521 votes, while Lib Dem Ross Laird took 1721.
It comes shortly after the shock news that SNP deputy leader Angus Robertson lost his Moray seat to the Conservatives’ Douglas Ross.
Speaking to the News, Ms Rowley said she was “delighted” with the result, adding she was particularly proud to become Midlothian’s first female MP.
She said: “I’m delighted and very, very proud - I’m proud of the campaign we ran, it was very positive.
“I’ve had a brilliant campaign team here in Midlothian and we have worked really hard.
“Every day I’ve become more confident because the messages we have been getting from people have been so positive.”
Ms Rowley, 27, said she felt Labour’s positive performance so far could be put down to a good campaign across the board from both Jeremy Corbyn and Kezia Dugdale.
She added: “On the doorsteps people are just fed up of any talk of the constitution, another referendum and Brexit.
“People just want to be focusing on the issues.”
The SNP’S Owen Thompson said: “You win, you lose some.
“National swings clearly had a big impact here, our opposition parties turned it on the referendum or devolution matters.
“You know what it’s all about when you get into politics, just this time it wasn’t to be.
“It’s too early to say what is next for me.
“We will keep putting forward our positive message.
“I’m disappointed to only have been Midlothian’s MP for two years, there was still work to be done.
“But I wish Danielle all the best.”
Conservative candidate Chris Donnelly was upbeat despite finishing third. He said: “I am absolutely delighted. It has built on the council election we had last month. We have turned Midlothian into a three-way marginal. Every Conservative vote in Midlothian counts.”
“It was mainly independence which came on the doorstep but also the amount of housebuilding and infrastructure especially in Penicuik and the Midlothian West areas.”
The full Midlothian result - Danielle Rowley (Lab) 16,458; Owen Thompson (SNP) 15,573; Chris Donnelly (Con) 11,521; Ross Laird (LD) 1721. Votes polled - 45,344. Turnout 66.4%