The SNP achieved a shock victory in the Labour heartland of Cowdenbeath.
Annabelle Ewing continued the party’s run of success in the Fife constituency, where Labour candidate Alex Rowley had won by a 5,488 vote majority in a 2014 by-election following the death of Helen Eadie.
Ms Ewing said it was an honour to be the first SNP MSP for Cowdenbeath and paid tribute to Mrs Eadie.
She said: “I am absolutely thrilled to have been elected tonight. It was a big challenge for the SNP to take this seat and we have done it with some style.
“It’s a sensational result for the SNP and I very much look forward to getting on with the job.
“I’m very proud indeed of the campaign we fought.
“It was an entirely positive campaign where we offered people a vision of the country that we want to build.
“We offered people hope that Scotland can be a better place to live for their families and communities.”
The results of the Cowdenbeath poll were: SNP 13,716; Labour 10,674; Conservative 4,251; Lib Dems 1,094.
Mr Rowley, the deputy leader of Scottish Labour, said: “It’s not a good night for Labour, that’s for sure.
“Labour in this election has created a debate about the future of Scotland.
“No matter what the result is, we intend to continue that debate.
“Fife and Scotland as a whole is facing cuts in services – health, education and vital public services.
“We need to have a debate about how we fund these services.”
Of the 54,596-strong electorate in the Cowdenbeath constituency, 29,857 people cast votes, with a percentage turnout of 54.7%.
In the Dunfermline constituency, Labour’s Cara Hilton lost her seat to Shirley-Anne Somerville of the SNP, turning another by-election result of 2014 on its head.
Ms Somerville said: “Tonight certainly looks as if it’s shaping up to be a great night for the SNP in Fife and in Scotland as a whole.
“That has a large part to play because of the achievements we’ve achieved in the nine years of government under the leadership of Alex Salmond and of course now Nicola Sturgeon.
“But we know we need to do more, to do more in Dunfermline and west Fife.
“We need to do more throughout Scotland and we are pleased that the electorate put their faith in the SNP to carry on that message in the next five years.”
There was a 57.2% turnout in Dunfermline, where 33,008 of an electorate of 57,740 voted.
The Dunfermline results were: SNP 14,257; Labour 9,699; Conservative 5,797; Lib Dems 3,156.