After four years and a state Supreme Court battle, and with the clock ticking to the end of the school year, the Philadelphia School District and its teachers' union have reached a tentative contract agreement.

The deal, which comes 1,383 days after the last contract expired, would run through 2020. It was struck with handshakes Thursday night with both sides determined to meet their self-imposed deadline of the end of the term — Tuesday for students, Wednesday for teachers.

"I believe that it's going to add some stability for our members, as well as the children of Philadelphia," Philadelphia Federation of Teachers president Jerry Jordan said Friday. "Although it does not have everything we wanted, it is certainly more than our members have been dealing with for the last five years."

Jordan, who said he was "delighted" to have a deal, did not disclose terms of the contract pending its presentation to his nearly 12,000 members — teachers, counselors, nurses, secretaries, aides, and other school staff — over the weekend. Union members are scheduled to vote on the contract Monday night.

Superintendent William R. Hite Jr. said he was pleased with the settlement, which he had identified as a priority for several years running.

"We just wanted to get a contract that recognized the hard work of our teachers, because they are a critically important part of our work," Hite said. "The fact that we were able to come together is really important."

Neither leader would discuss how much the agreement would cost the district, but one source with knowledge of the talks described the deal as "expensive" and said it "may require layoffs to fund it."

The source said that there were "significant" work rule concessions on the union's part, but that they would not yield savings for the district.

Mayor Kenney called the tentative pact "an important step."

"Schools that attract and retain quality teachers are essential to the success of the district and of Philadelphia," the mayor said in a statement. "Over the last few years, we've seen how the absence of a contract has jeopardized the district's hard-won stability and hurt our city's ability to attract businesses and families."

Jordan called it the toughest negotiation he has seen since he became a member of the negotiating team in 1992 — and that includes the 2000 contract talks, set against the backdrop of a state takeover and weakening of the union's power.

"This was a fight right until the very end," he said of the current negotiations. "There were a lot of issues that were still on the table that were pulled off right at the end."

The protracted negotiations were wearing, Jordan said, but so was the knowledge that members were working with no salary increases, spending money out of their own pockets to provide basics for students. It was also tough to watch some teachers and others leave the district because they couldn't absorb any more of a financial hit for teaching in Philadelphia, he said.

Both Hite and Jordan said they believed the deal would bring stability and hoped that it would help the district retain and attract new teachers.

"Hopefully it will eliminate the numbers of teachers who are looking to leave the district simply because they're stuck," said Hite.

The final issues were work rules and finances, Jordan said.

The last time points of a major contract proposal were made public, last fall, the PFT said no to a four-year deal  that included "step" increases — pay bumps for years of experience — and incentive bonuses for educators in hard-to-staff schools.

But that pact would have included no retroactive pay or cost-of-living increases. Jordan also objected to the bonuses, saying that the money could better be used elsewhere.

What is not clear is how the district will pay for the pact, which presumably will cost more than its rejected fall offer of $150 million. In a budget adopted late last month, the School Reform Commission allocated $150 million for the deal. It is already projecting a deficit by fiscal 2019, and that would rise to several hundreds of millions by 2022.

After years of negotiations that proceeded at a glacial pace — sometimes, the sides would go months without formal talks — things began heating up in May. Kenney, Council President Darrell L. Clarke, Councilwoman Helen Gym and Gov. Wolf were all pushing to get the deal done, Jordan said. A state mediator also was involved.

As Clarke put it, "People made it clear that we wanted a contract resolved." In the last several weeks, the two sides were at the table almost daily, including some weekends.

Even with bitter public actions — some teachers recently took a day off in part to protest the lack of a contract — Jordan and Hite described the negotiations as cordial.

"Certainly there are times when both parties have become angry about another's proposal, but we've maintained a very professional decorum," Jordan said.

"It wasn't acrimonious," Hite said. "But it was intentional, it was focused. It was continuous. There were times when I'm sure all groups wanted to throw up their hands and say, 'OK, that's it,' but we stayed with it."

That included October 2014, when the SRC voted to cancel the contract. It believed it had the power to do so under the state law that created the commission. The PFT fought the action, ultimately prevailing before the Pennsylvania Supreme Court.

The superintendent and union chief remained in contact throughout, Hite said, even when their teams were not formally negotiating. Both leaders are calm and measured, both in public and in private.

Clarke said he thought the PFT deal was "fair and equitable" to both sides. Gym said it would bring "some level of parity" to teachers.

"The money that was on the table addresses to its best possibility many years of not having a contract," the Council president said.

But he suggested that funding the contract would be a stretch.

"The simple reality is, we still have fiscal challenges as it relates to funding sources," Clarke said. "That will play out in a different theater."

In recent years, the city has put up more than $400 million in new money for its school system, much of that while the state cut or barely increased funding to the district. Most recently, the city notified the schools that a reassessment of commercial properties would mean a base of at least $65 million annually in new money  — which proved key to the deal.

Leaders can't continue to tax Philadelphians to pay for schools without contributions from Harrisburg, the council president said, but Clarke indicated he was willing to go to bat to fund the contract.

"The city is ponying up a lot of money — way beyond the level that we should have," Clarke said. "At the end of the day, we are not going to let our kids not get an education."

Gym, a district parent and longtime education activist, said the deal was "an important signal that we're looking at a new chapter with the district and the school staff and the PFT," and "a big step forward."

She characterized it as "a huge investment" and said it would "require the city and state to deliver on their promises to Philadelphia schools."

The general PFT membership meeting has been called for 6 p.m. Monday at the Liacouras Center, with doors opening at 4 p.m. Members must be physically present to vote, and representatives from the American Association of Arbitration will be on hand to count the paper ballots.

Some schools have graduations and other end-of-the-year events on Monday, and Jordan said it might be a challenge for some school staff to be there.

"It's the hand that we've been dealt," Jordan said.

Members are scheduled to receive the full text of the contract Saturday, and will also have access to a webinar with Jordan.