Scottish Liberal Democrat leader Willie Rennie has taken the Fife North East seat from the SNP.
The politician, who had secured his 2011 seat through the list vote, beat SNP candidate rival Roderick Campbell by 3,465 votes.
Mr Rennie received 14,928 votes, an increase of 15% from 2011.
He said: "It feels fantastic to have won North East Fife back for the Liberal Democrats. A big majority of 3,000 against a Nationalist tide."
Mr Rennie added: "It's a tremendous result for the Liberal Democrats in North East Fife."
In his victory speech, he said it had been a "positive, uplifting campaign" and added: "I've had the time of my life in this campaign."
- SNP in 'historic' win but no majority
- Tories beat Labour to be second party
- Greens push Lib Dems into fifth place
- Labour's Dugdale 'heartbroken' by result
- Tory Davidson takes seat from SNP
- Greens' Greer becomes youngest MSP
- Former Labour leader hopeful loses to Tories
- SNP wipes out Labour in Glasgow
He appeared at the count with two toy pigs in his hand, a reference to a photo opportunity at farm while out on the campaign trail.
Alex Cole-Hamilton, of the Liberal Democrats, also won Edinburgh Western from the SNP, with 16,645 votes - a 42% share.
The party also comfortably held both Orkney and Shetland.