The SNP has finished as comfortably the biggest party in the Scottish council elections despite the Conservatives making big gains.
The Tories increased their 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 – eight more than in 2012 – while Labour dropped to 31 in Glasgow.
The Conservatives increased their number of councillors in the city from one to eight and the Scottish Greens also had a good result, winning seven seats, while the Liberal Democrats lost their only councillor.
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.
- Follow live coverage of Scottish local election results
- Brian Taylor’s analysis of the results
- Election results postcode search
SNP leader Nicola Sturgeon, the country’s first minister, said her party had “won this election today”.
She added that it had secured more seats, more votes and more councils than its rivals, as well bringing nearly 40 years of Labour administration to an end in Glasgow and becoming the largest party in all of Scotland’s major cities.
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.
Speaking as she arrived at the Edinburgh count, 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”.
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, an increase of two, while the Conservatives jumped from 11 seats to 18 and Labour dropped by nine seats 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.
With all 32 councils having declared their results, the SNP finished on 431 councillors, an increase of 31 seats.
The Tories won 276 seats, an increase of 164, meaning they replaced Labour – which was down 112 seats to 262 – as the second largest party across the country.
There were also 172 independent, 67 Liberal Democrat and 19 Scottish Green councillors.
No party has managed to win majority control of a council – meaning they will all either be run by coalition or minority administrations.
The final results in Aberdeen showed the SNP on 19 seats, up three on 2012, 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.
- Rubbish candidate elected in Ayrshire
- Land probe councillor loses seat
In neighbouring Dundee the SNP went from 16 seats to 14, while Labour gained one seat, giving them nine councillors, while the Conservatives gained two – taking them to three.
There were also two Liberal Democrat councillors elected, doubling their total from the previous election, and one independent.
In North Lanarkshire, which had traditionally been a staunch Labour area, the SNP jumped by 11 seats to 33 – 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 won a seat.
The election used the single transferable vote system (STV), with voters ranking candidates in order of preference.
The system makes it difficult for any one party to win overall control of a local authority, with many being run by coalitions or minority administrations.
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.