The site of Longannet power station in Fife has been chosen by a Spanish train manufacturer as the location for a new factory, employing 1,000 people.
However, it is reliant on Talgo winning a major contract to build trains.
The firm said the factory will get the go ahead if it wins the deal to build over 50 trains. The trains would be used on the high speed rail line between London and Birmingham.
Talgo has the backing of Fife Council and Scottish government.
The Madrid firm said it will go ahead with the factory near Kincardine if it wins an initial order to build new trains.
However, the contract they want is worth £2.75bn.
The decision will not be made until early 2020, and with four others bidders vying for this giant contract, Talgo are by no means certain to win.
Earlier this month there were a series of controlled explosions at Longannet power station.
The station was closed in 2016, bringing an end to coal-fired power production in Scotland.
Shirley-Anne Somerville, Dunfermline and West Fife MSP, said: "It's excellent news that Talgo has selected Longannet as the preferred site for their new UK manufacturing facility, and builds on West Fife's record as an attractive location for investment.
"This new facility will bring huge opportunities for local economic development, and has the potential to bring hundreds of new jobs to West Fife. Talgo will be well placed to tap into a skilled local workforce, and benefit from excellent links to the rest of the country."
Mark Ruskell, Scottish Green MSP for Mid Scotland and Fife, said: "This is excellent news for the community in West Fife - the end of the coal age can be the beginning of a vibrant, low carbon industry in central Scotland and Talgo's commitment to 1,000 new jobs will be transformative.
"The rail infrastructure in place was key to the company choosing this site, and I'm excited to see how this can pave the way for more innovative and ambitious freight and passenger rail in Scotland."
Paul Lewis, managing director of Scottish Development International said: "With our public and private sector partners, we've worked intensively for many months to deliver the optimum proposal and to secure Scotland and Fife as the preferred location for Talgo's investment, so this announcement today is great news.
"The quality and skills of the workforce in the Fife area, combined with the strength of the business environment, will help Talgo realise its vision of establishing a world-class high value manufacturing facility for the rail sector, bringing benefits to Fife, Scotland and the UK as a whole."
A ScottishPower spokeswoman said: "It is great news that Talgo has selected Longannet as their preferred site to host a major new train manufacturing and testing facility in the UK.
"The decision recognises the geographic, infrastructure and transport benefits the site offers, and could potentially lead to significant employment and economic benefits for the local area."