CHICAGO (Reuters) - Illinois has negotiated lower credit rating termination triggers for its interest-rate swap deals with banks, which stood to pocket fat fees if the state is downgraded to junk as soon as next month, a spokeswoman for the governor’s office said on Monday.

Without this step, downgrades to the first level of junk by S&P or Moody’s Investors Service could have forced the cash-strapped state to pay the banks as much as $39 million in fees to end the swaps, according to the Illinois Comptroller’s office.

Eleni Demertzis, the governor’s spokeswoman, said the rating levels that would trigger the termination of four swaps - two with Barclays Bank, and one each with Bank of America and JP Morgan - were dropped a notch to the second level of junk - BB with S&P or Ba2 with Moody’s.

Illinois moved an uncomfortable step closer to the previous triggers this month with downgrades to one notch above junk by S&P and Moody’s. S&P warned the state could fall to junk - a first for any U.S. state - if it fails to enact a budget for fiscal 2018 that addresses a big structural deficit. The new fiscal year begins on July 1.

After hiring swap and legal experts, the state last year renegotiated the deals with the banks, lowering the termination triggers to the first level of junk ratings. The ratings trigger for the largest swap deal with Deutsche Bank that has a termination payout of about $70 million was changed last year to BB or Ba2.

An impasse between Illinois’ Republican governor and Democrats who control the legislature has left the nation’s fifth-largest state without a complete budget for nearly two straight fiscal years.

Lawmakers ended their spring session on May 31 without a deal for an unprecedented third fiscal year. Since then, House Democrats launched a new round of budget hearings. There have been no signs of a deal.

The swaps, aimed at hedging interest-rate risk, are related to $600 million of outstanding variable-rate debt that Illinois sold in 2003 with a final maturity in 2033. The deals proved costly to Illinois after interest rates dropped in the wake of the Great Recession.

Demertzis said terms of the renegotiated swap deals were not immediately available. The state also ended the need for letters of credit on the bonds last year by placing the debt with banks for a two-year term.