Labour and the SNP last night formed a historic coalition to lead Scotland's capital city for the first time in 16 years.

The two parties have signed an agreement to work together to run the City of Edinburgh Council for the first time since 1992-1996. It follows what were described as "intense negotiations" in the wake of Thursday's local government elections.

Final details of the agreement will be thrashed out over the coming days, but it means work will continue on the controversial £770 million trams project that will run between Edinburgh Airport and St Andrew Square.

Labour group leader, councillor Andrew Burns, will lead the council, with the SNP's leader, Steve Cardownie, his deputy.

Mr Burns claimed the alliance will allow Edinburgh to move forward with certainty.

He said: "After listening to the will of the electorate and after intense negotiations over the last few days, I am delighted that we have managed to reach an agreement to lead the city of Edinburgh for the next five years.

"Edinburgh electors gave a very clear mandate to Labour and the SNP, delivering 38 out of 58 councillors. A Labour-SNP coalition will now provide the stability and certainty needed to move Edinburgh forward."

Mr Cardownie added that the parties' similar economic policies will help benefit residents in the capital.

He said: "The SNP looks forward to working in partnership with the Labour group with a progressive and exciting agenda to meet the challenges the city faces.

"With this strong partnership we are best placed to ensure Edinburgh serves its citizens well and emerges from the recession quickly and strongly.

"Our groups' economic policies are almost one and the same and we are confident they will deliver for the people of the city."

The agreement follows an unsuccessful attempt to reach an all-party alliance.

Labour will now nominate a candidate for the position of Lord Provost, while the SNP will nominate a Deputy Lord Provost.

A Labour spokesman added: "Despite not being a multi-coalition, this deal will provide Edinburgh with the strong leadership it desperately needs."

With Labour retaining control of Glasgow, and confident of taking control in Aberdeen, he added: "We are delighted because in Scotland's two largest cities, Labour will form the administration.

"There are other negotiations going on across the country, but potentially Labour could lead double the number of councils as the SNP."

The spokesman added: "The trams project will continue as is currently agreed, as the current arrangement to St Andrew Square."

It is understood that an outline agreement has been reached, with further details and policy negotiations expected in the coming days.

City of Edinburgh chief executive Sue Bruce said: "I look forward to working with the new administration, and indeed all councillors, over the next five years.

"A successful council needs a partnership between the elected members who set the direction and policies, and the officers charged with putting that into practice.

"Together, our responsibility is to ensure that we take Edinburgh forward and make a real difference to the people who live and work here."

The first meeting of the new council will take place on May 17, when the leader and deputy leader will be officially confirmed.

Elsewhere, as the political make-up of Scotland's town halls continued to take shape, another definite outcome was the SNP-led multi-coalition in Midlothian, which will include the council's solitary Green Party member, Ian Baxter, and former Tory, Peter de Vink.

Meanwhile, Labour appears likely to finalise a coalition deal with the Conservatives in East Lothian and form administrations in South Lanarkshire and Inverclyde, with support from Tories at both councils.

The budget deal between Labour and the Tories in Stirling earlier this year is also expected to deliver an anti-SNP coalition.

The only other likely Labour-SNP coalition will be in the affluent Glasgow suburbs of East Renfrewshire. In East Dunbartonshire there appears to be no definitive picture emerging.

In Fife, speculation is mounting that Labour will do a deal with the four independent members and try to form an administration. A coalition of independents and the SNP appears likely in Argyll and Bute.

Scottish Conservatives leader Ruth Davidson has urged disillusioned Liberal Democrats to switch their support to her party, telling them there "is a home for you with the Scottish Conservatives".