Illinois could go down in history as the first U.S. state with a "junk" credit rating.

The rating firm S&P Global Ratings says it will probably give the state that embarrassing distinction if lawmakers fail to reach a budget deal by the start of the fiscal year on July 1. It would be the third straight year Illinois can't pass a budget.

Illinois is already in a severe budget crisis, with $15 billion in unpaid bills, a quarter-trillion dollars owed to public employees and cash levels so low that soon it won't be able to pay lottery winners.

A downgrade could make things even worse by causing borrowing costs to rise and giving investors even more reason to avoid its debt.

"Illinois is now at risk of entering a negative credit spiral," S&P warned on June 1.

Illinois already has the dishonor of being the state with the lowest credit rating, which is like a credit score for major companies and governments.

Neither S&P nor Moody's has ever downgraded a U.S. state to "junk," a rating that signals heightened risk of default.

Some struggling cities and counties have lost their investment-grade ratings in recent years. Stockton, California, and Detroit were downgraded to junk before they filed for bankruptcy in 2012 and 2013, respectively. Puerto Rico was cut to junk in 2014 ahead of its bankruptcy earlier this year.

Moody's said only a "very small" percentage of the 8,500 local governments in the U.S. have below investment-grade ratings.

Related: Powerball players may fall victim to Illinois budget crisis

Illinois's credit rating was downgraded to one notch above junk on June 1 by both Moody's and S&P after the legislature completed its session without a budget deal.

"Time is running out," Governor Bruce Rauner said on Twitter on Tuesday. The Republican urged lawmakers to pass a compromise plan to "bring real changes to our broken system."

Rauner's office did not respond to a request for comment.

Political paralysis has created a backlog of unpaid bills in Illinois totaling about $15 billion, or approximately 40% of the state's operating budget. That's about triple the level of outstanding bills from April 2016.

But that's not all: The state doesn't have nearly enough money to cover what it owes retired teachers and other state workers. Moody's estimates that the state has $251 billion in what are known as unfunded pension liabilities.

It's gotten so bad that Illinois may not be able to pay lottery winners. Powerball and Mega Millions ticket sales could be halted in the state if no budget deal is reached by Wednesday.

The fear is that the budget problems in Illinois will only get worse because a downgrade could put further stress on the state's finances.

"The unrelenting political brinksmanship now poses a threat to the timely payment of the state's core priority payments," S&P warned.