(Reuters) - The Kansas Legislature approved a plan on Friday to pour more money into public schools to address funding inequities between districts and keep the state Supreme Court from closing schools.

Lawmakers were working under a June 30 deadline set by the high court to enact a constitutional school funding formula that addresses disparities between rich and poor districts. Without it, the public school system statewide will be shut down.

After the legislature ended its 2016 session this month without addressing the matter, Governor Sam Brownback ordered legislators back for a special session that began on Thursday to cobble together another $38 million to satisfy the court.

The Republican-controlled House and Senate overwhelmingly passed the bill. It would increase aid to poor school districts for 2016-17 by diverting money from other parts of state government, mostly using proceeds from the sale of the Kansas Bioscience Authority.

Brownback, a Republican, has said he would sign the measure.

A legal battle over school funding has been raging for years in Kansas. The Supreme Court in February rejected a new funding formula enacted by the state in 2015, saying it was inequitable and came up millions of dollars short for schools in poor districts. The legislature passed a bill in April to fix the problem.

But the court agreed with four school districts that filed the lawsuit, ruling in late May that the fix was inadequate.

The legislative fire drill over school funding comes as Kansas struggles with sinking revenue.

The state budget is feeling the effects from action taken by Brownback and the legislature in recent years to cut corporate and other income taxes with the hopes of helping the state compete with bordering Missouri and other states for business development and jobs.

On Wednesday, the nine-member state finance council, which is composed of the governor and legislators, voted 8-1 to borrow a record $900 million from other state funds to support the budget in the cash-poor first quarter of fiscal 2017. Kansas last year tapped the other funds for $840 million, which will be repaid next week, according to the governor's office.

The state's reliance on one-time revenue measures to plug budget holes led Moody's Investors Service to place a negative outlook on Kansas' Aa2 credit rating and Standard & Poor's to warn it could downgrade its AA rating.

(Reporting By Karen Pierog; Editing by Jacqueline Wong)