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.