Campaigners have dropped plans to seek a judicial review over the future provision of health services in Surrey.
The Cranleigh Village Hospital Trust (CVHT) has reached an agreement with NHS Surrey following mediation talks.
NHS Surrey has agreed to keep the cottage hospital open for now while it refurbishes an existing health centre on the High Street site.
CVHT will push ahead with its plan to build a new hospital on an alternative site in Knowle Lane.
The agreement signals a breakthrough in the long battle over the provision and location of health services in Cranleigh.
Health chiefs favoured redeveloping the existing hospital, bringing an end to in-patient care at the site and closing 14 beds.
But CVHT began legal action to seek a judicial review over the decision.
It favoured building a new facility on the Knowle Lane site with the potential for both NHS and nursing home beds.
If the plan progresses, both sides will work together to provide health services from the new facility.
Nick Vrijland, who chairs CVHT, said he was delighted by the outcome.
"This is a good day for the Cranleigh community and NHS Surrey," he said.
David Clayton-Smith, who chairs NHS Surrey, said: "I am pleased that we have been able to find a workable resolution and put an end to the judicial review proceedings."