Alex Salmond's hopes of sweeping SNP gains in Scottish council elections have been dented after Labour won a morale-boosting victory in Glasgow and secured the most seats in Edinburgh and Aberdeen.

Johann Lamont, leader of Scottish Labour, was jubilant after her party secured a majority in Glasgow, its most significant political power base, despite widespread predictions it would struggle to remain the largest party and faced losing control to the SNP.

After Labour lost the popular vote and a swath of seats in the city in last year's Holyrood elections, Friday's result sent a warning to Salmond. While the turnout in Glasgow was at a historic low at just 32.42%, Labour claimed the result, if reflected in a Holyrood poll, would have seen Nicola Sturgeon, the deputy first minister, lose her seat.

Lamont said the result was "fantastic". She said it would boost Scottish Labour's efforts to overcome their humiliating defeat at the Scottish parliament elections: "I believe we've got a real chance again to serve the people of this country. We're on the road back to where people have confidence and trust in us again."

But there were strong SNP performances in other cities and rural areas. For the first time, the party is now in overall control of councils, winning in Dundee and Angus, and it is the largest party in Perth, Stirling and North Ayrshire.

However, the results were short of what Salmond had hoped for, coming weeks before he launches the SNP's campaign for the independence referendum.

But he insisted these were significant gains. "The SNP has won seats from Labour, from the Lib Dems and from the Tories in all parts of Scotland, urban and rural," he said. "We set ourselves the target of securing more councillors and we have met that target with around 60 extra councillors.

"This is a tale of two governments. The Lib Dems and Tories have had a disastrous day, feeling the full force of the Scottish people who have rejected their damaging austerity agenda in favour of the SNP locally and nationally.

"This year the SNP has secured our first two overall majorities in Dundee and Angus and the SNP has become the largest political party in 10 local authorities, far more than in 2007. That is a major step forward for the SNP and for Scotland."

By mid-afternoon on Friday, the elections expert Professor John Curtice said the average change in the share of vote across Scotland since 2007 was up 6% for Labour and the SNP was 4% higher based on assessing results from the four largest cities and two county-based councils. The early results suggested that both parties were making gains at the expense of the Conservatives and the Lib Dems which were down 2% and 8% respectively.

After also coming second in Fife, the SNP failed to win Edinburgh, where it had been in coalition with the Lib Dems, who suffered a humiliating rout after being widely blamed for the Edinburgh trams debacle – with the project late, over-budget and dogged by allegations of corruption – and saw their council leader, Jenny Dawe, unseated.

Labour became the largest party in Edinburgh, taking 20 seats, and is now clear favourite to form a ruling coalition, likely to include the Scottish Green party, which won three more seats to take six in total.

The SNP met Salmond's pre-election goal of remaining the largest party by the number of councillors elected and of overtaking Labour as the largest party by share of the vote, as the SNP consolidated its hold on many councils along the east coast.

With 1,223 seats up for grabs in all 32 councils, the number of SNP councillors jumped by 57 to 424, reaffirming the party's dominance of Scottish politics. Labour's overall number of seats jumped too, by 58 to 394. The Lib Dems were humiliated, haemorrhaging votes, and lost 80 seats down to 71 seats. They fell well behind the Conservatives, who dropped only 16 seats down to 115 seats.

Labour took overall control or became the largest party in a swath of councils, taking the most seats in Aberdeen, the oil-rich city on Salmond's doorstep, Dumfries and Galloway, Fife, East Lothian and West Lothian, and taking overall control of West Dunbartonshire . It also took control of Renfrewshire council, the home territory of Derek Mackay, the SNP's local government minister and the head of its local council campaign.

Both Scottish Labour and the SNP were the major beneficiaries of the Lib Dem gloom, confounding the experience in the Holyrood elections 12 months ago when Lib Dem supporters switched in large numbers to the SNP and enabled Salmond to achieve his landslide victory.

In Inverness, the de facto capital for the historic Lib Dems' Highlands stronghold, the party performed strongly. This gave some reassurance to Danny Alexander, the city's Lib Dem MP and chief secretary to the Treasury, who has been a hate figure for many Scottish politicians for his prominent role in the UK government's spending cuts.

Ruth Davidson, the Scottish Tory leader, said she was satisfied with the results. The party was now in a pivotal position to help form ruling coalitions in several councils, including Edinburgh and Stirling, and was the largest party in the Borders and South Ayrshire.

She too said Salmond's advances had been stopped. "It's not been a good day for the SNP and it's put the brakes on Alex Salmond's juggernaut."

Willie Rennie, the Scottish Lib Dem leader, conceded: "This is a very distressing day. We have lost many, many strong community activists who have stuck up for their area for many long years.

These results should dispel any myth that the Liberal Democrats are only in the coalition for ourselves. We never were. It has always been about doing the right thing for the fortunes of the country."