Rail services on the East Coast Main Line are being brought back under government control, following the failure of the current franchise.
Operators Stagecoach and Virgin Trains will hand over control from 24 June.
The Department for Transport will run the service until a new public-private partnership can be appointed in 2020.
Transport Secretary Chris Grayling said it would smooth the transition to a new operator, but critics said it was evidence of private sector failure.
Mr Grayling said the franchise had failed because Stagecoach and Virgin Trains had “got their bid wrong”, overestimating the profitability of the line.
It is the third time in a just over a decade that the government has called a halt to the East Coast franchise.
The London to Edinburgh line has been run by a joint venture between Stagecoach and Virgin, since 2015.
The companies promised to pay £3.3bn to run the franchise until 2023, but at the end of last year it become clear they were running into trouble.
In February it was announced that the franchise would end early, leading to accusations the government was bailing them out.
A history of failure
This is the third time a franchise on the East Coast Main Line has failed.
In 2005, GNER signed a £1.35bn, 10-year deal in what was then the biggest contract in European railway history. One year later it was stripped of the route.
In August 2007, National Express agreed a £1.4bn deal, but then handed it back to the government in 2009 amid the financial crisis.
It was then government-run until Stagecoach and Virgin’s £3.3bn bid in 2015.
Read more: What went wrong at the East Coast Main Line?
Analysis: By Theo Leggett, business correspondent
To have one rail company fail to fulfil its contract may be regarded as a misfortune. To lose three looks like carelessness.
The government insists that the East Coast service is not failing, and will continue to generate revenue for the public purse.
It says Stagecoach and Virgin have only themselves to blame for their inability to make enough money from the line.
That may be true. But critics say that if operators keep over-bidding, then that suggests a problem with the tender process.
The assumptions made by the DfT when inviting bids have also been widely questioned.
Now the DfT wants to use the line as a model for a new type of franchise, based on a public-private partnership.
That may help to solve some issues – for example, reducing the friction between the track operator, Network Rail and the train operator.
But whether it will help to make the line viable for the new operator is open to question.
Mr Grayling said the companies had overestimated growth in passenger numbers and revenues and were having to reach into their own pockets to fulfil the terms of the franchise.
He told the Commons that Stagecoach and Virgin have lost almost £200m, but there had not been a loss to taxpayers “at this time”.
The rail companies have blamed their problems on Network Rail, saying it had failed to upgrade the line which would have allowed them to run more frequent services.
Shadow Chancellor, John McDonnell tweeted that he welcomed the move, which he said was implementing Labour’s Manifesto promise to renationalise the railways.
Green Party MP Caroline Lucas tweeted that public ownership should be extended to the rest of the rail network.
For the next two years the operator of last resort, overseen by the Department of Transport will operate the East Coast Main Line.
It will be advised by the engineering firm Arup.
In 2020 there will be another tender process for operating the franchise.
Mr Grayling would like to see closer co-operation between the state-owned Network Rail which owns the track infrastructure and the private train operators.
Despite their failure on the East Coast Main Line, Virgin and Stagecoach will be allowed to bid for future rail franchises.
Analysis: By Norman Smith, assistant political editor
For a government wedded to the benefits of the private sector and to leaving the railways in the hands of private companies, today’s decision is a significant blow.
It’s also further ammunition for a Corbyn Labour Party committed to renationalising the railways.
Mr Grayling may protest that this is only a temporary measure – but it is still the third time in just over a decade that a private company has had to be stripped of the East Coast Main Line contract.
There are also likely to be raised eyebrows that despite their failure, Virgin Stagecoach will still be able to bid to run the line again after it is transferred back into public private ownership in 2020.
And while memories of British Rail’s stale sandwiches may have faded – strikes, costly commuter fares, cramped carriages and failing companies are hardly likely to endear passengers to the current crop of private rail operators.
After looking into problems with the service, Mr Grayling said he was advised “that there is no suggestion of either malpractice or malicious intent in what has happened”.
He added that the firms have paid a “high financial and reputational price” in relation to the East Coast route.
Stagecoach said it had attempted to negotiate a new contract with the Department for Transport, without success.
Mr Grayling said passengers and staff would not be affected by the change to the franchise arrangement. He said season tickets, timetables and employment conditions would remain unchanged.