The Keystone oil pipeline spilled more than 5,000 barrels of oil on Thursday before workers took it offline, a large spill that comes days before operators hope to secure a key permit for a sister project.

A TransCanada crew shut down the Keystone pipeline at 6 a.m. Thursday morning after detecting an oil leak along the line, the company said in a statement. The leak was detected along a stretch of pipeline about 35 miles south of a pumping station in Marshall County, South Dakota.

ADVERTISEMENT

TransCanada estimates the pipeline leaked 5,000 barrels of oil, or about 210,000 gallons, before going offline. The company said it shut off the pipeline within 15 minutes of discovering the leak, and it's working with state regulators and the Pipelines and Hazardous Materials Safety Administration (PHMSA) to assess the situation.

According to PHMSA data gathered by environmental group Greenpeace in August, three pipeline operators have spilled more than 63,000 barrels of Canadian crude oil or refined produce in the United States since 2010.

The Keystone pipeline itself spilled an estimated 21,000 gallons of oil in 2011, and 17,000 gallons in April 2016.

The leak comes at an inopportune time for TransCanada, which is to expand its delivery network by building the Keystone XL pipeline.

Nebraska regulators are due to announce a permitting decision for the Keystone XL pipeline on Monday morning. The 830,000-barrel-per-day project would bring crude oil from Alberta, Canada to Nebraska, where it would join existing pipelines that feed refineries elsewhere in the United States.

President Trump in March signed a presidential permit allowing the company to build the pipeline, against which environmentalists have waged a years-long battle.

Then-President Barack Obama Barack Hussein ObamaMomentum growing among Republicans for Supreme Court vote before Election Day Warning signs flash for Lindsey Graham in South Carolina Majority of voters say Trump should not nominate a Supreme Court justice: poll MORE formally blocked the pipeline in 2015. But Trump revived it via executive order earlier this year, a move he often touts as one of the major achievements of his first year in office.

Keystone XL, if built, would cut diagonally through South Dakota, where state regulators have already granted construction permits.

But opponents of the project seized on Thursday’s spill, saying it should lead Nebraska regulators to reject the pipeline project as too risky.

“The [Public Service Commission] must take note: there is no such thing as a safe tar sands pipeline, and the only way to protect Nebraska communities from more tar sands spills is to say no to Keystone XL,” said Kelly Martin, the director of the Sierra Club’s Beyond Dirty Fuels campaign.

This story was updated at 7:27 p.m.