The Transport for Wales rail service is to be brought under Welsh Government control from next February.
Ministers have confirmed the takeover from KeolisAmey, with day-to-day services to be run by a publicly-owned company.
It follows significant falls in passenger numbers during the pandemic.
The Welsh Tories questioned how much nationalisation will cost taxpayers, while Plaid Cymru called for the Senedd to be recalled.
Economy Minister Ken Skates said the government had stepped in "to stabilise the network and keep it running".
"The last few months have been extremely challenging for public transport in Wales and across the UK. Covid has significantly impacted passenger revenues," he said.
KeolisAmey was awarded the franchise in 2018, taking over from Arriva Trains Wales.
It covers most of Wales' trains - including key commuter services such as the Valley Lines.
What is happening?
The financial risk of the Wales and Borders rail franchise, which is branded Transport for Wales (TfW), had already been taken over by taxpayers under a £65m agreement signed in May.
But from February next year KeolisAmey staff working on rail services will be transferred over to a publicly owned company, currently called Transport for Wales Rail Ltd.
It is happening under a part of railway law that allows for the creation of operators of "last resort".
Officials say the time gap between now and the start of the new operator will allow the Welsh Government to prepare the new operator for service.
A part of the original agreement is staying - Amey Keolis Infrastructure Ltd will continue to be responsible for infrastructure on the Core Valley Lines, where the South Wales Metro upgrade is taking place.
Keolis and Amey will also work with the Welsh Government quango Transport for Wales on improvements to the service - like rolling stock and ticketing.
Kevin Thomas, chief executive of KeolisAmey Wales, said: "In light of Covid-19, we recognise the need for Welsh Government to have a sustainable way forward for delivering its ambitious objectives for rail."
Challenged on the decision later on Thursday, Mr Skates told a Senedd committee that if the existing arrangements had continued it would have "led to a collapse by the operator and a catastrophic transfer then to the operator of last resort [Transport for Wales Rail Ltd].
"What we're able to do now is manage a careful transition, which will take us through to February, and then beyond, with the establishment of TfW rail limited," he said.
Deputy Transport Minister Lee Waters said: "The whole business model collapsed in the face of Covid because the revenue was not coming in and Keolis in effect were not prepared to shoulder their share of the pain."
Asked about the long-term costs of propping up the network, he said: "It depends on Covid. We don't know."
New trains 'paid for'
Ministers pledged to honour commitments worth more than £1bn to buy new trains and build the south Wales Metro.
"That will be delivered," Mr Skates said.
James Price, chief executive of Welsh Government quango Transport for Wales which oversaw the franchise and shared branding with it, said that rolling stock is "on the way" and "in essence is paid for already".
"What this allows us to do is to reduce the profit we pay to the private sector massively over time, and make sure that when the revenue comes back, it comes back in to the taxpayer."
Russell George, economy spokesman for the Welsh Conservatives, said: "Given the track record of the Welsh Labour-led Government, its decision to take control of our vital train industry has not filled me with any hope."
He said ministers should have consulted the Senedd on "how much this decision is going to cost the Welsh taxpayer".
"Eyebrows will be raised, too, on why any support is being left until February 2021," Mr George added.
Plaid Cymru transport spokeswoman Helen Mary Jones said it "could well be the right decision", saying her party "has always maintained that our railways should be brought into public hands and the government put passengers before profit".
But she said there were "crucial questions" on financial implications and the nature of the subsidiary.
"Decisions of this importance should be announced in the Senedd so that members can ask questions on behalf of the people of Wales," she said.
What is KeolisAmey?
KeolisAmey is a joint-venture between two European companies, and was awarded the Wales and Borders franchise in May 2018 in a £5bn contract.
It was the first time the Welsh Government had awarded the franchise.
Keolis is France's largest private sector public transport operator - but its major shareholder is state-owned French railway SNCF.
Amey is a former one-time UK company owned by Spanish infrastructure giant Ferrovial.
KeolisAmey took over services in October 2018. In January it emerged it had been fined £3.4m over the performance of services.
Rail unions backed the move.
RMT general secretary Mick Cash said: "There is huge public support for public ownership because privatisation and profiteering has never been an efficient way to provide value for money, and this is even more the case when extra funding has been needed during the coronavirus pandemic."
Manuel Cortes, general secretary of the TSSA, said: "This is a welcome and positive step from the Welsh Government, which will put our railways back in public hands and again shows the abject failure of privatisation."
Analysis by Daniel Davies, BBC Wales political correspondent
We are told passengers will not notice the changeover. The same trains, staffed by the same drivers and conductors, will arrive at platforms.
But there are new risks for the taxpayer.
Ticket sales have plummeted. So in May the Welsh Government announced £65m and an emergency agreement to help the service cope.
In practice, that means almost all the financial risks associated with the railway are borne by the government.
Profits and losses have moved from the private sector into the public sector.