League One Portsmouth are on the verge of salvation after administrators of the club struck a late deal with Portpin for the sale of Fratton Park.
A takeover by the Pompey Supporters' Trust can now be completed after the club
Their takeover is conditional on taking control of Fratton Park which was owned by the club's major creditor Portpin.
Portpin, led by Balram Chainrai, claimed they were owed £12m by the club and held Portsmouth's home as security.
The PST had offered £3m for the ground but with Portpin unwilling to sell at that price, administrators BDO went to the High Court to force the sale.
But it did not get that far, with an agreement reached out of court between administrators and Portpin, thought to be a figure of £3m plus add-ons.
It means the fans' group can now go ahead with their purchase of Fratton Park and BDO can start the process of finally bringing the club out of administration.
"It's fantastic, it's exactly the news we wanted. It's really exciting," PST chairman Ashley Brown told BBC Sport.
"It's taken a lot longer than we wanted but in the end we got the result we wanted. It's brilliant news, we're over the moon.
"Of course we believed it was possible otherwise we would not have put so much effort into it.
"There have been times where we thought we would definitely do it and times where we thought we wouldn't.
"Recently we've been very bullish, we've kept at it and we were right to as we've brought it home.
"The belief kept us going, we knew we were the right answer for the club and we all knew that we had to keep plugging away at what we wanted to achieve.
"This moment should be something special for all fans, not just Pompey. This should give a belief of what is achievable.
"We like to say we are the biggest community club in the country and we hope other clubs will follow.
"This club now has a very bright future. It is not going to be easy. We're going down to League Two but we have to accept that and use it as an excuse to rebuild."
Administrator at BDO Trevor Birch added: "I'm completely relieved. My reaction is that - relief that's is all finally over.
"It's taken quite a bit out of me personally. It's been a very difficult and complex case.
"It's been hugely frustrating, but at the end of the day it's all been worth it and Pompey are alive and kicking."
The club had been in danger of losing their 'Golden Share' - and effectively membership - with the Football League, who had warned Pompey they must come out of administration before the end of the season.
The PST have raised around £2m in pledges with fans' donating £1,000 each to save the club.
They are also backed by several High Net Worth individuals, who also support the club, and they have bankrolled the Hampshire outfit for several months now,
One of those HNW's is Iain McInnes and he will become chairman of the club as and when the PST takeover is complete.
This was the second case to determine the future of Pompey with the initial hearing in December adjourned.
It marks the end of several torturous years for a club that has been in administration twice in three years and suffered relegation from the Premier League to the Championship and now League One.
With another 10-point penalty on the way, a further relegation to League Two is expected.
On a day of drama at the High Court after two adjournments the case was finally heard and lasted only several minutes as Katharine Holland QC revealed an "agreement in principle" had been struck.
Holland asked for further time to seal the deal and after BDO returned at 15:00 BST several more adjournments followed before the judge declared it had been completed and the sorry saga was finally over.
It means Chainrai's four-year hold on the club is at an end.
Birch will now start the process of bringing the club out of administration, which is expected to be completed on 22 April.