The city and the Philadelphia School District announced an agreement Thursday to keep some schools available for weeknight and Saturday recreation programs that had been under threat of losing their seasons to budget cuts.

The city agreed to consolidate Recreation Department programs at 83 schools into 48 locations, and chip in $175,000 from the general fund to help pay for the cost to the district.

The district had proposed closing its buildings an hour earlier on weekdays, at 8 p.m., and entirely on the weekends to save $2.8 million in energy and staff costs. The calculated amount of potential savings since has been lowered to $1.6 million.

Under the agreement - and with the city's subsidy - the schools now will save an estimated $1.2 million, said School Reform Commission Chairman Pedro Ramos.

While Ramos, Mayor Nutter and a nearly full slate of Council members cheered the deal on Thursday, the schools still need to cut another $40 million by June - and next year's budget could be even more grim.

"The School District will continue to face significant funding challenges," Nutter said. "That means we're going to have to be that much more creative in our efforts to do the kind of programming that we want."

About 12,000 people - mostly children - would have been affected by the closures, which would have brought a premature end to athletic leagues, drama programs and other activities.

Council President Darrell L. Clarke said he thought that would send "mixed messages" at a time when city leaders are stressing the need for youths to be involved in positive activities.

"This would have been devastating for the kids," Councilman Bobby Henon said of the closures. "Thousands of kids who otherwise would have been on the streets in this city, blighted with crime."

The deal keeps the 48 locations open until 9 p.m. on weekdays and for up to eight hours on Saturdays through March 17. Recreation officials believe that will enable all 154 groups to finish their seasons.

Some teams may have to share space for practices, and groups may have to move their events to new times and locations.

"A combination of all those things brought us to this conclusion without hurting any groups," said Leo Dignam, the deputy recreation commissioner for programs. "We're able to fit . . . I'm going to say everybody, because I haven't found one we haven't been able to place."

A few accommodations might have to be made for drama programs that have scheduled performances beyond March 17, said Councilman Brian O'Neill, whose Northeast district relies heavily on school buildings for activities.

O'Neill said the cash-strapped district "brought this to our attention" that "we weren't paying our fair share."

"I know it took a lot of work . . . to come up with a number that satisfied everybody, that the city was willing to pay and the school district was willing to accept," he said. "It seems pretty much everybody is being made whole."

The mayor, he said, was "personally" involved in cementing the deal Wednesday night.

The city originally felt that the $2.8 million in savings was inflated. On Thursday, the district said that would have been the figure if all 83 buildings were closed from Jan. 1, and assuming each would have stayed open until 10:30 p.m.

Ramos, who recently became SRC chair, admitted that "nailing down and updating numbers within the district has been a challenge."

The district announced on Jan. 19 that a $61 million budget gap would have to be closed by June.

Some cuts have already been identified - laying off 91 school police officers, slashing summer school programs, ordering some nonunionized administrative employees to pay toward their health insurance and take pay cuts and furlough days.

A newly-hired chief recovery officer, Thomas Knudsen, has been tasked with finding ways to cut, and Ramos said another $40 million still needs to be trimmed.

"You have to attack the gap," Ramos said. "What we don't want them to do is to be stuck in analysis paralysis and to be ringing their hands as to what reactions will be."

Ramos, Nutter and Clarke all said they were at least buoyed by the willingness of everyone to cooperate and find a solution.

"Both sides negotiated hard," O'Neill said, "and walked away happy."