York City's future at Bootham Crescent home has been secured.
The troubled club feared being made homeless after ground owners Bootham Crescent Holdings PLC had agreed to sell the site to Persimmon Homes.
A joint statement issued by York City and the other two parties confirmed the club can stay put.
The statement said: "Agreement has been reached to enable the football club to continue to play at Bootham Crescent for the foreseeable future."
Although an agreement has been reached in principal between York City, Bootham Crescent Holdings PLC and Persimmon Homes, it will take some time to sort out the legal niceties.
The joint statement added: "The necessary details will however be made available when all the legal arrangements have been concluded.
"Until that time the parties involved will be unable to make any further statements on this matter."
The outcome ends a two-year battle by the club's board, which was formed from a Supporters' Trust, to safeguard City's future after former chairman Douglas Craig announced in December, 2001 that the club was for sale and would resign from the League unless a buyer was found.
Director Jason McGill said: "We are delighted to have reached an agreement regarding the future of Bootham Crescent.
"It has taken much hard work and many sleepless nights, but subject to contract, we have achieved our aim of ensuring York City has a home for next season and for the future," Gill told the York Evening Press.
Player-manager Chris Brass has also welcomed the development as he looks to bring success on the field.
He said: "This is one of the biggest pieces of news in the history of the club. For myself as manager it's great to know that the future has been safeguarded and hopefully now I can take the team forward.
"The board has been working hard to secure this but it still goes through your mind 'will there be a York City in 12 months ?' Now we can planning knowing that the club has a future.
"It will help me in contract negotiations and hopefully attracting players to the club, knowing that they can have some security and be part of something which is moving forward, rather than the fear of being a statistic if the club couldn't continue."