The SNP has won an historic third term in government at Holyrood, but it appears Nicola Sturgeon's party may not have secured a second majority.

The Tories, meanwhile, enjoyed their best ever Scottish Parliament result as a record number of Conservative MSPs were voted in.

Ruth Davidson's party now seems certain to form the official opposition at Holyrood, following a string of election night successes.

In contrast, Scottish Labour suffered another disappointing election result, with leader Kezia Dugdale left "heartbroken" that her party has now apparently slipped into third place in the Scottish Parliament.

Ms Dugdale failed in her bid to win the Edinburgh Eastern constituency and had to rely on the Lothian list to be returned to Holyrood.

Labour also lost all of the constituencies it had held in Glasgow to the SNP, a repeat of the fate it suffered in last year's Westminster election.

But Ms Dugdale insisted she will remain as the leader of her party "no matter what".

Ms Davidson took the Tories from fourth to first in Edinburgh Central, winning the seat from the SNP.

The Tories made another gain from the SNP in Aberdeenshire West, where Alexander Burnett ousted Dennis Robertson, while Scottish Conservative deputy leader Jackson Carlaw and Oliver Mundell, the son of Scottish Secretary David Mundell, won the Eastwood and Dumfriesshire seats from Labour respectively.

The Liberal Democrats made some gains, with their leader Willie Rennie winning the North East Fife constituency, while children's charity worker Alex Cole-Hamilton was elected as the new MSP for Edinburgh Western, taking the seat from the SNP.

But the Scottish Greens overtook the Lib Dems to become the fourth largest party at Holyrood, after returning a number of MSPs on the regional lists.

Green co-convener Patrick Harvie was elected in Glasgow, while the party now has two MSPs from the Lothian region.

Holyrood's youngest ever MSP is also a Green, with 21-year-old Ross Greer elected via the West of Scotland list.

Speaking after watching Labour's vote crumble across Scotland, Ms Dugdale said: "It's not clear yet who's come second and third, although the direction of travel seems to suggest that the Tories are going to become the official opposition in Scotland."

Asked how that made her feel, she added: "Heartbroken, without question. You can see from the reaction of the Tories that they are indeed surprised about how well they've done tonight."

Ms Dugdale said: "This election was always going to be tough for the Scottish Labour Party, just a year after a painful general election defeat.

"But I am proud that our campaign rose to the challenge of offering an alternative vision of what could be done in our new, more powerful parliament."

But with the constitution now a key issue in Scottish politics, she said her "determination to try to move the Scottish debate on" from the arguments of the 2014 independence referendum had cost Labour votes.

She added: "There's no doubt that our defeat for the Labour Party is painful, but it is not the end of our campaign. We will continue to argue for Labour values, Labour ideas and Labour principles.

"The work to renew the Scottish Labour Party so it is fit to serve the people of Scotland continues."