Grangemouth petrochemicals plant has been saved following a last-minute deal.
The 800 workers who were due to lose their jobs at the Falkirk plant - Scotland's largest industrial site and its only refinery - were told the news at 11am on Friday.
It came after the Unite union confirmed it would now "embrace" a survival plan in an effort to reverse a decision by Swiss-based owner Ineos to close the business.
Calum MacLean, chairman of Ineos' petrochemicals division, told a news conference a "great cheer" went up from workers as he told them their jobs were safe.
But he said "very limited redundancies" would have to be made.
Asked by one reporter if he had held a gun to Scotland's head, he replied: "I don't think that's the case."
He pointed out that Ineos had invested £1bn in the business and would invest another £300m to secure its future for at least the next 15 years.
Another £300m will be invested at the site, Ineos says He said it was "only right" that by making such a "huge investment" the company had to make sure it had a "long-term sustainable base".
The agreement was to see fuel production resume at the company's oil refinery on Friday after a shutdown of more than a week.
The closure would have been a major setback for the Scottish National Party, which is leading the campaign for Scotland's independence from the UK.
Scotland's First Minister Alex Salmond said: "This news is a tremendous fillip for the workforce and the whole Grangemouth community, following what could have been a potential disaster."
Later, in an interview with Sky News, Mr Calum MacLean declined to say how many redundancies would be made. He said the £300m would be spent on building a new gas terminal at the site.
Asked what he thought of union tactics during the negotiations, he said it would have "saved a lot of traumatic effects" if union officials had begun the talks a week ago with the same attitude they had had over the past two days.
The closure would have been a huge blow for Alex Salmond Jim Ratcliffe, chairman of Ineos Group, said: "This is a victory for common sense. Unite advised employees to reject change and vote for closure. Thank goodness people finally came to their senses. Grangemouth now has a great future."
Ineos said Unite had made a "dramatic U-turn" and had agreed to a three-year pay freeze, no strikes for three years, and moving to a "modern" pension scheme.
Earlier, Unite's general secretary Len McCluskey said shop stewards had decided to accept the company's survival plan "warts and all" in the wake of the closure decision.
Unite's Scottish secretary, Pat Rafferty, said: "Grangemouth is the powerhouse of the Scottish economy - it now has a fighting chance of upholding this crucial role into the future.
"Obviously today's news is tinged with sadness - decent men and women are being asked to make sacrifices to hold on to their jobs, but the clear wish of our members is that we work with the company to implement its proposals."
Ineos caused shockwaves on Wednesday when it announced it could not continue to operate its loss-making petrochemicals division, leaving hundreds of staff at risk and many more contractors facing the axe.



The new curved Galaxy Round will be available only in South Korea
Steve Ballmer is to leave Microsoft in 2014
The housing market recovery is reflected in the GDP growth
Lower gas and electricity demand over the hot summer hurt growth
New video shows a miners' leader (circled) who was shot dead minutes later
The footage shows police with guns drawn, apparently before trouble started
Film-maker Rehad Desai says the new evidence is 'damning
Nissan's Sunderland operation has grown to build new models
Ed Miliband said Sir John was making "Labour's argument"
David Cameron's spokesman said it was an "interesting contribution"
The Grangemouth plant employs 1350 workers and 2000 contractors
Unite says a majority of the workfoce have rejected the company's demands
Ineos Grangemouth site manager Gordon Grant talks with Unite's Pat Rafferty
Too big for your pocket? Nokia's Lumia 1320 has a very large screen
The 'strike price' gives EDF a guaranteed rate for producing electricity
Anti-nuclear campaigner Theo Simon
George Osborne visited a Chinese nuclear power plant last week
The project has caused outrage in some areas
The link will cut journey times between the north and south
The first phase of HS2 from London to Birmingham
Last week British Gas announced a 9.2% increase in prices
Electricity prices are rising faster than those for gas
JPMorgan executives give evidence over the 'Whale' losses to US Senate