The result means the island constituency is no longer Scotland’s safest seat, with Nicola Sturgeon claiming it is now a “top target” for her party at the next election in 2021.
Lib Dem candidate Beatrice Wishart won 5,659 votes after a strong turnout of 66.5 per cent, making history in the process by becoming the first female parliamentarian elected to represent the area.
However, the SNP mounted a strong campaign in the build up the vote and secured a 14.4 per cent swing away from the Lib Dems.
The party’s candidate Tom Wills finishing second with 3,822 votes.
The result means the Lib Dem majority has been more than halved from 4,895 in 2016 to only 1,837. Turnout was also higher than the 62 per cent recorded at the last election.
The by-election was sparked by the resignation of long-standing MSP Tavish Scott, the former Scottish Lib Dem leader, who had represented the constituency since 1999.
Ms Wishart said she was honoured to become Shetland’s first female MSP after the “roller coaster” campaign and said the constituency had “once again rejected Scottish Nationalism”.
“My work will start on Monday to get the Scottish Government to take action on its empty promises for fair ferry funding, to improve nursery provision, mental health care and broadband.”
Alistair Carmichael, the Lib Dem MP for Orkney and Shetland, claimed the result would be a “bitter disappointment” for the SNP.
“Just last week Nicola Sturgeon was here for her third visit in a month, telling us it was going to be neck and neck. If that was neck and neck, all I can say is that’s some neck,” he added.
However, the First Minister said she was “proud” of the campaign her party had fought and said the result meant the seat was now easily winnable at the next election.
“The Lib Dem majority has been slashed, with a 14 per cent swing to SNP. What was the safest seat in Scotland is now a top SNP target for 2021. The tide is turning,” she added.
The result contained more bad electoral news for Scottish Labour, which fell from third place in 2016 to sixth, with Johan Adamson winning just 152 votes.