The announcement came after its New Zealand-based owners failed to find a buyer after putting the South Ayrshire aviation hub up for sale 18 months ago.
The airport, which generated £61.6 million for the Scottish economy last year, mainly caters for holidaymakers using budget airline Ryanair. But it has suffered a sharp drop in passenger numbers and a slump in cargo contracts.
Deputy First Minister Nicola Sturgeon said discussions between the Scottish Government, owners Infratil, Scottish Enterprise, three Ayrshire councils and prospective buyers were advanced. She said they had reached a stage where it is "clear no private investor is able to commit to a successful purchase" on a timescale acceptable to the owners.
Confirming Prestwick would have closed without state intervention, Ms Sturgeon said the talks had included possible public subsidies "within state aid rules" to help a new owner in the early years following a takeover.
The airport has been on the market for more than 18 months and was valued a year ago at around £10.5m on a combined price tag with Infratil's other UK airport, Manston in Kent.
Infratil paid Stagecoach £33.4m to buy the airport 12 years ago as the no-frills airlines sector boomed.
However, the airport has been hit by a marked downturn in passenger numbers and freight in recent years, while Ryanair has increasingly shifted its services to Edinburgh.
The councils have pledged £6m in funding to help rescue the airport, which directly employs some 300 people with a further 1400 jobs dependent or associated with it.
Ms Sturgeon said the airport's loss would have been a devastating blow for the economy. She said it continued to be "fully open for business" and the Scottish Government was confident it could be turned around.
She said: "We believe Prestwick Airport can have a positive future. It will require investment and it will take time. However, we believe it can be returned to profitability. We also estimate the cost of closure to the public purse would be very significant and this is an important factor in our decision."
The completion of the sale to the Scottish Government is expected to take six weeks.
Katy Clark, Labour MP for North Ayrshire and Arran, welcomed the decision but called for more detail.
Brian Donohoe, Labour MP for Central Ayrshire, added: "This is a development which I welcome and we need now to ensure concentration is steered towards new routes and new airlines coming into the airport."
Bill McIntosh, leader of South Ayrshire Council, said Prestwick was "critically important" to the local economy.
However, fears have been raised about the long-term implications of a state takeover and when it would be possible to hand it back to private ownership.
Scottish Liberal Democrat MSP for the South of Scotland Jim Hume said: "Questions remain about how much effort the Scottish Government is making to get the substantial private businesses, who benefit from the airport, to support its renewal."
He said Ryanair had announced £500m in profits and previously received government grants. He suggested others involved in the wider aerospace businesses could have a role.
Mr Hume added: "At the moment the Scottish Government doesn't have a plan or a price. These will need to be set out clearly before we know for sure that a long term future can be achieved."
Conservative Transport spokesman Alex Johnstone MSP said: "It is going to take an enormous effort to get the airport back in to profit and make it sustainable for the future. That will involve a significant level of restructuring and the Scottish Government has to have the courage to do what's necessary, rather than pouring money into something without accruing any benefit."
Labour's Infrastructure spokesman James Kelly said it would be a "big challenge ahead to bring the airport back into profitability" and find a buyer to make it viable.
He added: "Where is this money coming from and will there need to be more than the initial investment to turn Prestwick around?"
A spokesman for Transport Scotland said the government "will negotiate a purchase price with Infratil that will aim to maximise the return for taxpayers' investment".