Mr Rennie, who became synonymous with colourful photo opportunities during the election campaign, increased the Lib Dems’ share of the vote by 15.4 per cent in the constituency, beating the SNP’s Roderick Campbell into second place.
The party also took Edinburgh Western from the nationalists, with candidate Alex Cole-Hamilton increasing the Lib Dem share of the vote by 14.1 per cent.
There were also wins in Orkney, where Liam McArthur increased the party’s share of the vote by 31.6 per cent, and in Shetland, where former leader Tavish Scott held on to his seat.
The results in Orkney and Shetland were interpreted as partly a reaction to a legal action taken against Lib Dem Orkney and Shetland MP Alistair Carmichael last year.
Four constituents raised the action under the Representation of the People Act 1983, claiming he misled voters over a leaked memo about Nicola Sturgeon before the election.
But judges ruled it had not been proven beyond reasonable doubt he had committed an “illegal practice”.
A jubilant Mr Rennie said: “It is good to be winning again - and so good to return north-east Fife to the Lib Dems.”
He added: “I have had the time of my life in this campaign - you may have noticed! - but this was a campaign focussed on north-east Fife; an area where I grew up and where my family had a shop in Auchtermuchty and Cupar. It is a huge privilege to reresent north-east Fife.”
Rennie’s victory prompted an overjoyed reaction from Tim Farron, who tweeted a cartoon of Mr Rennie on a slide.
The joke referred to the Scottish Lib Dems’ election launch, during which the soon-to-be-MSP went down a volcano slide at a children’s play centre.