Fourteen new trains are to be built at a Hitachi plant in County Durham, securing hundreds of jobs.
The plan safeguards 700 jobs with a £500m investment for the Newton Aycliffe site.
The plant and its workers had faced an uncertain future with an upcoming gap in its order book before work begins on HS2 (High Speed 2) trains.
Money blog: Britons don’t want ‘thoughtful’ cash alternative
British transport group First Group, leasing firm Angel Trains, and Hitachi have reached a deal to order 14 five-carriage trains to run in 2027 on the new Carmarthen-London route and East Coast Mainline service.
They will also provide further capacity on existing Lumo and Hull Trains services.
A further £460m investment for 13 five-car trains is an option for the plant.
Jim Brewin, UK and Ireland chief director for Hitachi Rail, said the contract was “a positive step forward” and “just recognition for the hard work and patience of our teams”.
He thanked local MPs and North East mayor Kim McGuinness, saying they had “worked tirelessly in support of this private sector investment”.
Angel Trains added it was the first announcement of its kind in six years.
During the general election campaign, Prime Minister Sir Keir Starmer visited the plant and said the workforce was “staring down the barrel of devastating job losses”.
On Friday, he said: “I made a promise to the workforce of the Newton Aycliffe factory and today, I’m delivering on that promise.”
Earlier this week, the Department for Transport announced South West Rail, c2c and Greater Anglia would become the first three rail companies to be nationalised under government plans to create Great British Rail.