MONTGOMERY, Ala. — Alabama Gov. Robert Bentley on Thursday signed a compromise bill that divvies up hundreds of millions of dollars of oil spill settlement funds for a mixture of paying debts, Medicaid and roads.

Under the plan, Alabama will take a smaller lump sum payment of about $640 million, instead of being paid in installments over 18 years.

“We can bring this money forward and use it right now to pay off debts, primarily, but also to shore up Medicaid,” Bentley said.

The governor signed the bill Thursday at a ceremony at the Alabama Capitol. The Alabama Legislature gave final approval to the bill Wednesday night after lawmakers agreed to a compromise on how to spend the money.

The plan will steer $400 million to repay money borrowed during past budget shortfalls. It will also steer $120 million to the state’s Medicaid program over the next two years and $120 million to build roads in two coastal counties.

Bentley said the plan, “buys us some time” in dealing with large shortfalls in the state’s Medicaid program.

“We still need long-term funding but it buys us some time,” Bentley said.

The state is receiving the money to compensate for economic damages incurred statewide from the 2010 oil spill in the Gulf of Mexico. The disaster was the largest offshore oil spill in U.S. history.

The bill was the major product of a special session called by Bentley on a proposed state lottery and other ways to try to get additional money to the state’s Medicaid program. After lottery legislation died, the oil spill settlement bill took center stage.

Bentley said he was disappointed that lawmakers did not approve the lottery bill which would have put the decision to voters on whether to create a state lottery to fund Medicaid.

“We should have given them that right,” Bentley said. Alabama is one of six states without a lottery.