A pipeline company was fined nearly $3.35 million on Thursday for causing the worst California coastal spill in 25 years.

A judge issued a fine and penalties against Plains All American Pipeline for a 2015 spill that sent 140,000 gallons of crude oil gushing onto Refugio State Beach in Santa Barbara County, northwest of Los Angeles. The spill from a corroded pipeline blackened popular beaches for miles, killed wildlife and hurt tourism and fishing.

Federal inspectors found that Plains had made several preventable errors, failed to quickly detect the pipeline rupture and responded too slowly as oil flowed toward the ocean.

Plains operators working from a Texas control room more than 1,000 miles away had turned off an alarm that would have signaled a leak and, unaware a spill had occurred, restarted the hemorrhaging line after it had shut down, which only made matters worse, inspectors found.

Last year, a Santa Barbara County jury found the Houston-based company guilty of a felony count of failing to properly maintain its pipeline and eight misdemeanor charges, including killing marine mammals and protected sea birds.

Plains apologized for the spill and paid for the cleanup. The company's 2017 annual report estimated costs from the spill at $335 million, not including lost revenues.

The fine was well short of the more than $1 billion in penalties prosecutors had sought. However, additional damages could be levied at a July restitution hearing.

"We take our responsibility to safely deliver energy resources very seriously, and we are committed to doing the right thing," the Houston-based firm said in a statement Thursday. "We are sorry that this release happened, and we have and will continue to work hard to re-earn the trust of area residents."

The spill crippled the local oil business because the pipeline was used to transport crude to refineries from seven offshore rigs, including three owned by Exxon Mobil, that have been idle since the spill.

Plains has applied for permission to build a pipeline.

Conservation groups that oppose offshore drilling in the area are opposed.

"It's great to see Plains All American Pipeline held accountable for the ecological catastrophe they brought to the Gaviota Coast in 2015. That stretch of coastline has some of the last untouched bluffs and beaches in all of Southern California," Mark Morey, chairman of the Santa Barbara chapter of the Surfrider Foundation, said in a statement. "But the idea that this company would be permitted to continue operating in such a naturally rich and unique area is absurd."