The deal, which is worth about £97m, was confirmed at the SNP's annual conference in Aberdeen by Transport Minister Derek McKay.
Ferguson's had previously been named as the preferred bidder for the contract.
The firm was saved by businessman Jim McColl's Clyde Blowers Capital after it went bust on 15 August. Mr McColl is one of Scotland's wealthiest people.
Originally formed in 1902, Ferguson's employed 77 staff at the time of the administration appointments.

The Buchan Alpha is due in Lerwick, weather permitting, on Friday.
The production vessel is to be brought in to anchor for the removal of some of the deeper parts of structure.
The next stage is being brought alongside at the newly extended Dales Voe deepwater quay to be dismantled for recycling.
It is expected to take about 17 months to take Buchan Alpha apart.
Jobs created
The work will be done by the French company Veolia, and 35 jobs will be created by the project.
Originally a drilling rig, Buchan Alpha started production from the Buchan field in 1981.
It was taken out of service in May by operators Repsol Sinopec Resources UK.
Ferguson's shipyard on the Clyde has won a Scottish government contract to build two new ferries.
[NEXT_CONCEPT]
An offshore vessel said to have produced almost 150 million barrels of oil over 36 years is scheduled to arrive in Shetland for decommissioning.