The SNP has held the Fife North East seat with just two votes.

It was the final Scottish seat to declare in the UK general election, after a third recount.

The SNP's Stephen Gethins won 13,743 votes while Elizabeth Riches of the Scottish Liberal Democrats polled 13,741.

A spokesman for the Lib Dems said they were considering a legal challenge to the result, the joint third closest in UK general election history.

It is also the narrowest victory since Mark Oaten won Winchester for the Lib Dems by two votes in 1997.

'Review the outcome'

Mr Gethins saw his majority cut from 4,344 in 2015.

Sir Menzies Campbell, who occupied the seat for 28 years, said the re-counts had been too close to call.

He said: "At one stage they were thinking of cutting a card or tossing a coin. To lose by two is particularly hard.

"I've no doubt we'll review the outcome and whether any kind of challenge is appropriate."

Close calls - the narrowest general election wins

Image copyright Getty Images

In 1886 the narrowest recorded majority in a British general election was just zero - a record held by John Edmund Wentworth Addison, the Conservative candidate for Ashton-under-Lyne, now part of Greater Manchester.

He drew with his Liberal Party opponent but, under different electoral rules, became MP on the casting vote of the local mayor in his role as returning officer.

Addison held the seat at the 1892 election and stood down from parliament in 1895.

In 1910, Conservative candidate Henry Duke won by just one vote in Exeter while Abraham Flint, standing for National Labour in Ilkeston, Derbyshire, in 1931 won by two votes.

Among the smallest majorities recorded since 1945, is the 1974 win for the SNP by a young Margaret Bain, later Ewing, who took East Dunbartonshire from the Conservatives.

She won by just 22 votes - but this general election saw it surpassed by an even narrower win when the SNP's Pete Wishart saw his near 10,000 majority slashed to just 21 in Perth and North Perthshire.