U.S. District Judge Carl Barbier ruled Wednesday that BP cannot get back payout money given to companies affected by the 2010 oil spill in the Gulf of Mexico.

The decision is based on an agreement that the oil company made with these companies, which resulted in them receiving hundreds of millions of dollars after they claimed the oil spill had a negative impact their business, according to the Associated Press.

BP opposed the ruling, arguing that the businesses are getting money because of a flaw in the funding formula, and that their claims against BP are not legitimate.

Geoff Morrell, spokesman for BP, said in an email that the payouts should be returned to the company because the agreement was misinterpreted by the settlement program, The National Law Journal reported.

"This misinterpretation resulted in claimants receiving awards well in excess of what they are entitled to under the settlement agreement - in some cases by millions of dollars - or awards that weren't warranted at all." Morrell said.

"While BP agreed to the settlement contract, we consistently disagreed with the now judiciary overruled loss calculation methodology, and we have consistently and publicly maintained that nothing in the contract or the release impairs BP's legal right to recovery of overpayments once this misinterpretation was corrected."

However, Barbier, who ordered for the funding formula to be changed several weeks ago, said BP must comply with the agreement, The Associated Press reported. He added that the payments that BP agreed to came with a provision, which stated that later court actions cannot make any changes to them.

The ruling is the latest roadblock in BP's effort to keep its liability for the spill from growing. The company is faced with the possibility of having to pay $50 billion because of the incident.