An agreement has been reached to stop offshore manufacturing firm BiFab falling into administration, the Scottish Government has announced.

It comes after two days of intensive talks, chaired by First Minister Nicola Sturgeon, who returned early from a UN climate change conference to take part.

The deal means work will continue on the firm's current contract for the Beatrice Offshore Windfarm in the Moray Firth.

At the centre of the issue was a dispute involving BiFab and the Dutch-owned contractor, Seaway Heavy Lifting (SHL), over a particular payment.

The agreement will result in BiFab being able to receive payments "to alleviate immediate cash flow issues".

Ministers also met trade unions Unite and the GMB to discuss the deal and say they will remain in close discussion with BiFab regarding the company's longer-term prospects.

Burntisland Fabrications Ltd (BiFab has a workforce of 1400 employees, contractors and subcontractors at its yards in Burntisland and Methil in Fife and Arnish in Lewis.

The company, which makes equipment for the oil and gas industry and the renewable energy sector, had earlier filed an administration notice due to cash flow problems linked to its contractors.

On Thursday, hundreds of BiFab workers marched on the Scottish Parliament to rally support for their cause.

Commenting on the deal, the First Minister said: "I am pleased that after an extensive series of talks over the last week and two days of intense negotiations we have been able to broker a commercial agreement that lifts the threat of administration from BiFab and allows work on the current contract to continue."

Sturgeon added: "I know that this has been an anxious time for people employed at BiFab, as well as their families and the wider communities of Burntisland, Methil and Arnish and the trade unions have ensured that the importance of this company was made clear to all companies involved.

"All companies including BiFab have had to take difficult decisions to secure this outcome.

"While this deal lifts the immediate threat of administration, we recognise that there is a lot of work still to do to secure the long term position."