Senators sent a school funding package to the governor by the slimmest of margins early Sunday following late-night drama that sent lawmakers into a whirlwind of fury and relief and nearly derailed a session’s worth of work.

The Senate and House played a high-stakes game of chicken over competing methods for extending work past a midnight deadline while GOP senators filibustered debate on a compromise deal to add about $500 million in funding to public schools over the next five years.

With Gov. Jeff Colyer’s blessing, the state now will have to convince the Kansas Supreme Court that the plan adequately funds public schools.

“It certainly is a significant amount of additional funding, and we hopefully have addressed the concerns of the formula itself,” said Rep. Melissa Rooker, a Republican from Fairway who served on the House education committee that produced the plan.

“I hope that what we have provided is deemed to be the good-faith effort that I know I put into it,” Rooker said. “It’s not perfect, but this is the process, as wild and woolly as it is. I don’t think you ever find a perfect solution, so we did our level best.”

Colyer and Kansas Attorney General Derek Schmidt implored lawmakers to pass a bill in time for Schmidt to review it before an April 30 deadline for filing motions. But Republican leaders in the Senate stalled for two days after the House passed a plan on Tuesday, waiting for support to materialize for rewriting the constitution and neutering the high court’s authority on school finance.

When that didn’t work, the Senate passed a plan that offered just $275 million in new funding and went to the negotiating table Friday in hopes of trading its policy programs for lesser money than the $525 million in the House plan. The House refused to blink.

Then, on Saturday, the House inserted its original plan into a Senate bill and added just two of the Senate programs designed to improve academic performance of children. Hours passed before Senate leaders reluctantly allowed debate on the matter.

Senate Majority Leader Jim Denning, R-Overland Park, complained his notes and negotiating materials on school finance had mysteriously disappeared from a table in his office. Sen. Molly Baumgardner, the Louisburg Republican who worked on negotiations with the House, said House GOP leadership chose not to bargain in good faith.

“I don’t support this bill,” Baumgardner said. “There are no changes we can make. We are stuck with the work that came over here from the House.”

Senate President Susan Wagle, R-Wichita, worked with a group of conservatives to defeat the House bill, but came up two votes shy. She said the funding package wouldn’t satisfy the plaintiff school districts and probably wouldn’t meet expectations of the Supreme Court. The five-year schedule of increases for K-12 education make it difficult to earmark money for other priorities.

“We’re here to do the right thing, not the popular thing,” Wagle said. “We have an obligation as elected legislators to balance the budget and make sure all the needs of state government are met.”

As senators debated school finance at length late into the night, it became obvious they wouldn’t take a vote before midnight. Sen. Mary Pilcher-Cook, R-Shawnee, and Sen. Gene Suellentrop, R-Wichita, weren’t even on the floor.

If the Senate didn’t pass a school funding plan before midnight, the session would end abruptly. Any unsigned and remaining bills would die, and the governor would need to call a special session to start from scratch on school funding.

To avoid such a fate, the Senate and House passed competing motions for extending the session, with the Senate version taking time away from the period lawmakers traditionally use for considering vetoes and unresolved matters.

With one minute to spare, the House adopted the Senate’s motion to extend the session.

“They were acting like children,” Rooker said. “Like spoiled children that didn’t get their way. And there’s another way. As senators, they have the opportunity to debate and vote up or down, amend, change, whatever. They shut down for two days and didn’t do their job. They filibustered all day and ran the clock out to the eleventh hour.”

The extension meant the Senate could stall no longer. Shortly after midnight, Pilcher-Cook and Suellentrop arrived just in time to cast their votes. With just 20 voting in favor and 21 needed to pass, Sen. Bruce Givens, R-El Dorado, switched his vote to put the tally over the edge.

Outside the chamber, educators gathering in a show of support erupted with cheering. Across the floor, representatives were relieved. The clock showed 12:24 a.m.

“I think there was some swallowing hard and taking a resolution that they didn’t like in order to try to go for the greater good tonight,” said Rep. Blaine Finch, R-Ottawa.

Rep. Tim Hodge, D-North Newton, said he felt good about passage of the plan, but he remained skeptical of the overall funding and the high court’s willingness to accept it.

He also wasn’t happy with the late-night antics.

“I guess it was expected, but I couldn’t believe the gamesmanship that we play with our kids’ educations,” Hodge said. “It shouldn’t come to that, year after year after year. ...

“So how I felt at that point? I’m glad it’s over, but it’s disgusting that we have to do it in the middle of the night.”