Media playback is unsupported on your device Media caption Nicola Sturgeon says the result is "a pretty clear emphatic win" for her party

The SNP has finished as comfortably the largest party in the Scottish council elections despite the Conservatives making big gains.

The Tories increased their total number of councillors by more than 160, including in areas that had previously been "no-go" for the party.

But the SNP has replaced Labour as the largest party in Glasgow, although it fell short of winning a majority.

Scotland's biggest city had been under Labour control for decades.

The SNP will now attempt to form either a coalition or minority administration in the city for the first time, after winning 39 seats - four short of a majority - while Labour dropped to 31.

The SNP has also replaced Labour as the largest party in Edinburgh and Aberdeen, as well as in North Lanarkshire, West Dunbartonshire and Renfrewshire, where Labour had won majorities in 2012.

But the SNP lost overall control of Dundee and Angus councils - the only two areas where it had secured majorities five years ago - as the Conservatives increased their number of seats.

The results mean no party has managed to win majority control of a council - meaning they will all either be run by coalition or minority administrations.

SNP leader Nicola Sturgeon, the country's first minister, said her party had achieved "a clear and emphatic victory" in the local elections.

And she said the "very, very good result" would provide a great launchpad for next month's general election.

Media playback is unsupported on your device Media caption Ruth Davidson says her party's councillors will focus on "local services and not constitutional division"

Ms Sturgeon added: "The SNP has won the council elections. We have more votes, more seats and are in the driving seat of more councils than any other party.

"SNP councillors and SNP councils will put their communities and the people of Scotland first."

The SNP is now the largest party in 16 council area - up from 10 in 2012 - and joint largest in a further three councils.

The Tories won seats in areas including Shettleston in Glasgow and the Paisley North West ward in Renfrewshire, which includes Ferguslie Park - two of the country's most deprived areas - and increased its support across much of the rest of the country.

'Things that matter'

Scottish Conservative leader Ruth Davidson said her party's success was evidence that people across Scotland were "looking for this Scottish fightback against the SNP".

Ms Davidson, whose party made opposition to an independent referendum a key part of its campaign, added that the party will "speak up for the millions of Scots who have had enough of the uncertainty and division of the last few years".

She pledged: "We will demand that politicians of all parties focus instead on the things that matter: restoring excellence to Scotland's schools and getting our economy back to health."

How the BBC calculates the 2017 result

By BBC Scotland political editor Brian Taylor

Let's talk numbers - there have been boundary changes which mean that some comparisons are made with "notional" outcomes in 2012, the last time these councils were contested.

On that count, the SNP are notionally down by a fractional seven seats. However, in terms of absolute numbers, the Nationalists have ended up with more councillors than in 2012.

Plus the SNP are the largest party in Scotland's four largest cities - including Glasgow, where jubilant supporters attended their ousting of Labour. They have waited decades for that.

Read more from Brian

Labour's support slumped across the country, with the party finishing third behind the SNP and Conservatives in Edinburgh - where it had been the largest party.

The SNP won 19 seats in the capital as Labour dropped to 12.

The Scottish Greens and Liberal Democrats also increased their number of councillors in Edinburgh to eight and six respectively.

The council had previously been run by a Labour-SNP coalition, after the parties took 20 and 18 seats respectively in 2012.

Sorry, your browser cannot display this map

Scottish Labour leader Kezia Dugdale said the results for her party across the country were "disappointing" but "not particularly a surprise".

She told the BBC News Channel the vote in Scotland had split on constitutional lines, with many unionists backing the Conservatives.

Ms Dugdale claimed: "Across Scotland, there has been a clear backlash against the SNP's plans for a divisive second independence referendum and anger over the SNP's woeful record running our schools, hospitals and public services."

With all 32 councils having declared their results, the SNP finished on 431 councillors, with the Tories on 276 seats, meaning they replaced Labour - which was down to 262 - as the second largest party across the country.

There were also 172 independent, 67 Liberal Democrat and 19 Scottish Green councillors.

'Real progress'

Scottish Greens co-convener Patrick Harvie said his party had "made real progress", having expanded its support in many parts of the country, including Glasgow and Edinburgh.

In 2012, the SNP won 425 seats, Labour 394, the Conservatives 115, Lib Dems 71 and Scottish Greens 14 - but boundary changes mean direct comparisons between the two elections are difficult, with the total number of seats having also changed.

The BBC calculates overall seat changes based on notional 2012 results, which estimate what the results would have been then if the new boundaries had been in place.

Image copyright Getty Images Image caption Thomas Kerr celebrates winning a seat for the Conservatives in the Shettleston area of Glasgow - which had traditionally been a staunch Labour area

The final results in Aberdeen showed the SNP on 19 seats, while Labour lost nine of its 18 seats and the Conservatives went from three to 11. The Lib Dems dropped from five to four.

But in Angus, the SNP dropped from 14 seats to nine, while the Conservatives doubled their number of councillors to eight. There were also nine independents and two Liberal Democrats, while Labour lost its only seat.

In neighbouring Dundee the SNP won 14 seats, two fewer than in 2012, with Labour on nine and the Conservatives three.

And in North Lanarkshire, which had traditionally been a staunch Labour area, the SNP jumped to 33 seats - one more than Labour. Meanwhile, the Conservatives - which previously had no seats on the council - won 10.

In Stirling, the Conservatives increased from four seats to nine, the same number as the SNP, while Labour dropped from eight seats to four and the Scottish Greens also picking up a seat.

The election used the single transferable vote system (STV), with voters ranking candidates in order of preference.

People aged 16 or over were eligible to vote, with more than 4.1 million people in Scotland registered.

A total of 1,227 councillors were elected across the country's 32 local authorities, with more than 2,500 candidates putting themselves forward.