ExxonMobil has lost a legal fight against environmentalists in its home state of Texas over air pollution at one of the oil giant's oldest refineries.

A Texas court ordered Exxon (XOM) on Wednesday to pay $20 million in fines for pollutants released into the air at the Baytown, Texas refining and chemical plant outside of Houston.

U.S. District Judge David Hittner cited "serious" violations that resulted in the release of about 10 million pounds of pollutants into the atmosphere.

The judge ruled in favor of the Sierra Club and Environment Texas Citizen Lobby, finding Exxon violated the Clean Air Act 16,386 times between October 2005 and September 2013.

The court found that Exxon enjoyed $14.2 million in economic benefits by delaying the installation of infrared imaging and other monitoring improvements at the facility, which makes everything from jet fuel to plastic.

"Today's decision sends a resounding message that it will not pay to pollute Texas," Neil Carman, clean air program director for the Sierra Club's Lone Star Chapter, said in a statement. "We will not stand idly by when polluters put our health and safety at risk."

In addition to the civil penalties, Exxon has also been ordered to pay the environmental groups' legal and expert fees.

Related: Trump denies Exxon permission to drill in Russia

"We disagree with the court's decision and the award of any penalty," Exxon said in a statement.

Exxon said it plans to consider its legal options, including appealing the ruling.

The environmental groups initially sued Exxon in 2010 over the Baytown facility, which is the largest petroleum and petrochemical complex in the US. Exxon won the initial lawsuit, but that ruling was reversed on appeal.

Exxon lost another battle last week when the Trump administration denied the oil giant's request to bypass sanctions to drill for oil in Russia.

Exxon is also being investigated for allegedly misleading the public and shareholders about what it knew about the dangers of climate change. The company has denied wrongdoing.