A long-closed hospital in a Pennsylvania county could soon be transformed into an educational space. The Upper Darby School District has agreed to purchase Delaware County Memorial Hospital, which has been vacant for nearly three years. A bankruptcy court recently approved the $600,000 deal.

Daniel McGarry, superintendent of Upper Darby School District, called the agreement a major step forward.

“It’s a big victory for the school district,” McGarry said. “It’s been a couple years in the making.”

Upper Darby school officials hope to renovate or potentially demolish the hospital and its adjacent buildings to make room for new classrooms. The plan aims to ease overcrowding at Upper Darby High School, which is next to the hospital, by eventually accommodating up to 1,000 students.

But there’s a catch. The sale must close by Aug. 13. If it doesn’t, the current owner, Prospect Medical Holdings, has the right to back out and abandon the site altogether.

Adding to the challenge is the hospital’s significant tax burden — nearly $20 million in unpaid taxes — which is currently being addressed in bankruptcy court. It’s unclear whether the school district will inherit any of the hospital’s tax debt.

The long-term cost of converting or replacing the hospital is also still unclear.

Not everyone supports the plan.

“I think it’s great they’re thinking outside the box and relieve the overcrowding,” Lansdowne resident Eric Aubrey said. “But I believe the hospital needs to remain a hospital.”

Despite the concerns, McGarry said the district has few other options when it comes to finding space.

“I’m sure there’s always a chance that a deal could fall through, I don’t want to focus on that,” McGarry said. “I want to focus on the fact that we are where we are right now. We’re going to move this forward in a positive direction.”

If the deal closes and the district opts not to renovate, demolition of the hospital could begin within months.