Scottish Liberal Democrats leader Willie Rennie took North East Fife as his party held on to a number of key constituencies.

In a mixed night for the party, Rennie took his constituency from the SNP, while children's charity worker Alex Cole-Hamilton won Edinburgh Western from the Nationalists.

"It's so good to return North East Fife to the Liberal Democrats," he said.

UK party leader Tim Farron tweeted his congratulations to the party's Scottish leader with a picture by STV's resident comic artist Neil Slorance inspired by Rennie's campaign.

The party also held both the Shetland and Orkney constituencies, with Tavish Scott and Liam McArthur re-elected in their respective seats.

There had been speculation that fall-out from the Alistair Carmichael "Nikileaks" scandal could impact on support for the party in both the island seats.

Campaigners mounted a legal challenge to his result in the 2015 general election, after he lied over the leaking of a memo which falsely claimed Nicola Sturgeon had told the French ambassador she would prefer Conservative leader David Cameron to the then Labour leader Ed Miliband as prime minister.

But when the votes were counted, the Lib Dems held on to both seats - which were the only constituencies they won in the 2011 Holyrood election.

The party lost their deposit in more than 40 seats, however, after receiving less than 5% of the vote, in areas including Airdrie and Shotts, Falkirk West and Moray.

The Scottish Greens secured six seats in total, one short of their best result in 2003.

In the regional list, Alison Johnstone returned to the Scottish Parliament and was joined by land reform campaigner Andy Wightman.

Mr Wightman said: "I am determined to bring bold ideas into parliament and will pursue issues such as local democracy and land reform with vigour."

In the west of Scotland, 21-year-old Green candidate Ross Greer became the youngest MSP yet, while Mark Ruskell was elected in Mid Scotland and Fife.

In the Highlands and Islands regional list, former SNP MSP John Finnie, who later served at Holyrood as an independent, was elected as a Green MSP.

He said: "It's great to be re-elected to represent this amazing part of Scotland, this time as a Scottish Green. Across the region the Green team have worked hard to reach more voters than ever before."

Green co-convener Patrick Harvie was placed second in the Glasgow Kelvin constituency with more than 6000 votes, pushing Labour into third place. Sandra White held the seat for the SNP. Harvie was elected from the Glasgow regional list.

This is the first Holyrood election in which the Greens fielded candidates in the first-past-the-post constituency section of the ballot.

UKIP candidate David Coburn was not elected in the Highlands and Islands region.

The party's UK leader, Nigel Farage, admitted Ukip had a bad night in Scotland as the Tories swept up unionist support.

He said: "Scotland is very, very difficult. The Conservatives have been resurgent in Scotland and have taken that unionist vote. Scotland has not been a success for us, but Wales is a big success."