THE SNP's Bill Walker has won the Dunfermline constituency just ahead of Labour with the Lib Dems' Jim Tolson, who was defending the seat, trailing in third.
It was another shock win for the SNP - one of many across Scotland as they swept to a majority government - as they had to come from third last time in Dunfermline.
With the Lib Dems suffering a huge backlash across the country from their decision to form a UK coalition with the Tories at Westminster, it had looked like Labour's Alex Rowley was on course to win back the seat for the party.
However, a late surge for the nationalists saw them narrowly gain their first election success in West Fife for either the Scottish or UK parliaments.
Mr Walker, currently a councillor for the West Fife villages, said in his victory speech, "It's a wonderful day for Dunfermline and Fife." He said voters in Dunfermline had responded to the positive message from the SNP.
Mr Walker and his party workers are heading to a victory celebration in Edinburgh hosted by Alex Salmond tonight (Friday).
Mr Rowley was disappointed but said it was an "excellent result given the results across Scotland".
Mr Tolson said it had been a "wonderful experience" to have served the area as MSP and wished his successor all the best in the role.
The Dunfermline result Bill Walker SNP 11,010 Alex Rowley Labour 10,420 Jim Tolson Lib Dem 5,776 James Reekie Conservative 2,093