Scotland's train services are to be run by a public sector body, the Scottish government has announced.
Dutch firm Abellio will stop running the ScotRail franchise at the end of March next year.
After this an "arms-length" Scottish government company will take over the running of services.
Abellio has been running the franchise since 2015 but had its contract ended early amid criticism over cancellations and performance levels.
All ScotRail staff will transfer to the new Scottish government-owned entity.
The arrangement is being made under powers which allow the Scottish government to take over the rail franchise without a bidding process.
Transport Secretary Michael Matheson said he was not able to say how long these "operator of last resort" arrangements would last for.
He said: "I have decided that it would not be appropriate to award a franchise agreement to any party at this time, either through a competition or a direct award.
"That is why I have confirmed that, from the expiry of the current franchise, ScotRail services will be provided in public hands through a company wholly owned and controlled by the Scottish government.
"This approach will provide a stable platform for ScotRail services and certainty for passengers and staff."
Scotland's railways have already been temporarily nationalised since March last year to help the service cope with the impact of coronavirus.
The Scottish government has spent £452m in support for ScotRail, along with the Caledonian Sleeper, after passenger numbers dropped dramatically as a result of lockdown restrictions.
Mr Matheson described Abellio's time in charge of ScotRail as "a difficult period" which had confirmed the franchise system was "broken and not working in the taxpayers' interest".
He told the BBC's Good Morning Scotland programme: "There have been periods where they have under-performed, which has resulted in us having to take direct action.
"It's also a time when we have seen our rail network expand, with more new trains... and a greater range of services to the travelling public.
"So it's been very much a mixed report card that we would give to Abellio, but one that we did not believe lived up to our aspirations."
Mr Matheson said passengers would get better value for money under the new set-up "because it will effectively cut out the company" which has been running the system.
This includes the company's "considerable" management costs, he said.
Kevin Lindsay, Scottish organiser of train driver union Aslef, said: "We welcome the beginning of the end of the failed franchise system here in Scotland.
"However, never again should people's railway ever be in the hands of the privateers.
"It's now for all us in the railway to build a railway that's accessible, affordable, and safe for the people of Scotland."
The TSSA union said: "This announcement is long overdue - much like many ScotRail trains were whilst Abellio was in charge."
The RMT union said public ownership would deliver significant benefits for Scotland's rail workers, passengers and taxpayers.
The "operator of last resort" model that the Scottish government will use is currently being used by the UK government to run the East Coast franchise by means of the arms-length London North Eastern Railway company.
In Wales, day-to-day services are being run by a publicly-owned company after a significant fall in passenger numbers during the Covid pandemic.
Scottish Tory transport spokesman Graham Simpson said: "The SNP government must be entirely honest about how much this will cost taxpayers and clear about what demonstrable benefits it is expected to bring to passengers.
"It is important that this is being motivated by pragmatism not ideology.
"This is the same government that can't even build a couple of ferries which hardly instils confidence in them having the competence to run a rail service."
Scottish Greens transport spokesman John Finnie said the announcement was "welcome progress".
He said: "Given Wales brought railways into public ownership last year, this has been a long time coming.
"Nationalisation of services is just the first step towards a greener, integrated public transport system which serves communities not shareholders."
Scottish Labour's transport spokesman Alex Rowley said: "When SNP ministers awarded the contract to Abellio they told us we would have world leading services but for far too many that was not the experience.
"The Scottish government could have acted on this much earlier, and it is their repeated failures that have led us to this point."
A statement from ScotRail posted to Twitter said: "We want to reassure you that we'll keep operating a reliable service to support the vaccine rollout and the opening up of the economy over the coming months."We'll work closely with Transport Scotland to ensure a smooth transition to the new operator, to deliver stability for customers and railway staff."
Privatisation of the railways in the 1990s was both radical and controversial.
Even some who had supported the privatisations of other state-owned assets such as BT and the electricity companies questioned whether breaking up British Rail and offering businesses franchises to run services would actually work out for the best.
They seemed to be proved right. The company that owned the lines, Railtrack, was brought back into public ownership as Network Rail. Some franchises proved unsuccessful or unviable so the state stepped in to keep the trains running.
The ScotRail franchise, despite plenty of controversies, was relatively free of trouble and has been operated by three separate companies over the years - Abellio now looks set to be the last.
In many ways though, Scotland's railways were more like a public private partnership than a business simply driven by the market. The Scottish government supported big improvements to the line between Glasgow and Edinburgh and the reopening of the Waverley Line in the borders.
For some, the renationalisation of Scotland's railway service will be seen as right or wrong as a mere point of principle. But the test for many passengers will be whether it results in better services or a greater degree of accountability.