An agreement has been reached to secure the future of manufacturing firm BiFab's yards in Fife and the Western Isles.

A Canadian company has acquired the firm in a deal brokered by the Scottish Government.

It was feared around 260 jobs could be lost by the summer if the yards in Methil, Burntisland and Arnish closed.

Cash flow problems brought BiFab, which manufactures structures for the offshore industry, to the brink of administration last year.

Construction firm JV Driver will take over BiFab through its subsidiary DF Barnes.

The Scottish Government will take a minority shareholding in the new company in order to demonstrate its commitment to the yards.

The First Minister Nicola Sturgeon visited the Methil site on Tuesday.

She said: "We are delivering on the commitment I made last year that we would stand by BiFab and work to secure a long term future for the company.

"We have been in negotiations with DF Barnes for a number of months and today is a significant step forward in our efforts to restore BiFab to its place at the centre of Scotland's marine energy industry."

She continued: "DF Barnes acquisition is a key milestone for all three BiFab yards and as a sign of our commitment to the company's future, the Scottish Government will maintain a close interest by taking a minority shareholding in the company.

"There is a lot of hard work ahead, and there is no magic bullet for these yards but the commitment of DF Barnes to securing a new future for the business at Burntisland, Methil and Arnish is a hugely positive step and I believe that gives BiFab the best chance of winning future contracts and securing new work."

DF Barnes CEO Jason Fudge said: "DF Barnes is excited to now have a major presence in Scotland.

"Scotland has been an admired world leader in the offshore oil and gas and renewable energy sectors and we are delighted to join with the employees of BiFab and the people of Scotland to ensure the continued growth of BiFab for the benefit of all.

"This is a great day for us."