In a blow to Oakland and its environmental agenda, a federal judge in San Francisco on Tuesday cleared the way for a company to export coal from a port in the city.

U.S. District Judge Vince Chhabria said city officials breached a contract with developer Phil Tagami and his Oakland Bulk and Oversized Terminal, or OBOT, project when they instituted a prohibition on coal handling and storage within city limits two years ago and then retroactively applied the ban to the marine terminal project.

In 2013, OBOT signed an agreement with the city giving the company the rights to build a $250 million shipping terminal near the Bay Bridge toll plaza. City officials said they had gotten assurances from the company that coal wouldn’t be stored or shipped there.

The contract was executed prior to the city passing any ban on coal, but it contained an exception that allowed the city to impose future regulations if they were necessary for health and safety reasons.

Chhabria, however, said there was insufficient evidence to support the City Council’s contention that coal and petroleum coke operations “pose a substantial danger to people in Oakland.”

Now Playing:

“In fact, the record is riddled with inaccuracies, major evidentiary gaps, erroneous assumptions, and faulty analyses, to the point that no reliable conclusion about health or safety dangers could be drawn from it,” he wrote. “Perhaps a more thorough investigation could result in a lawful determination that coal operations may be restricted at the facility, but in this case, the record was inadequate.”

The project, which would be the first coal facility of its kind in Oakland, calls for hauling the fossil fuel from mines in Utah, Wyoming and elsewhere and storing it at the waterfront site before shipping it overseas.

“I am delighted with the prompt and dispositive ruling,” said Robert Feldman, a lawyer for the shipping company.

The amount of coal and coke passing through the terminal is expected to be 5 million metric tons a year — more than what all of California currently exports.

The shipping terminal is a key piece of a 130-acre development that Tagami’s company, California Capital & Investment Group, has undertaken at the old city-owned Oakland Army Base. Tagami is a longtime friend of Gov. Jerry Brown and owns the seven-story building near Oakland City Hall where Brown and his wife, Anne Gust Brown, were married in 2005.

Concerns about the project surfaced in 2014, after Tagami’s shipping operator, Terminal Logistics Solutions, entered talks with four coal-mining counties in Utah. Leaders of those counties promised to invest $53 million in the Oakland terminal, on the guarantee that Utah coal would be exported from Oakland.

City Councilman Dan Kalb, the lead author of the ban, said City Attorney Barbara Parker would bring the council a set of options later this month to consider how to proceed with the litigation.

“There was more than substantial evidence that shipping this much coal through this one location has substantial health and safety impacts,” Kalb said. “We need to do whatever it takes within the law to hold firm in our opposition to this ridiculous proposal. The residents in that area, the workers of Oakland and the entire world need us to stop this export terminal.”

Mayor Libby Schaaf likewise said the legal battle isn’t over.

“This is a fight for environmental justice and equity,” she said in a statement. “Oakland’s most vulnerable communities have unfairly suffered the burden of pollutants and foul air for too long.”

Lawyers for the city argued that coal dust — particulates that fly into the air when pieces of coal are jostled against each other — would be particularly hazardous for low-income neighborhoods of West Oakland through which the material would be transported. Children in that industrial area are already prone to high rates of asthma and other illnesses.

But Chhabria said a consultant, Environmental Science Associates, hired by the city to study the possible pollution effects, failed to adequately consider the mitigation techniques promised by the company.

For instance, the judge said, the city ignored how the use of railcar covers and chemicals to suppress dust emissions would impact air-quality estimates. Chhabria said that was “a big mistake,” and called the floated concern that covered coal could be prone to spontaneous combustion “nothing more than generalized speculation.”

San Francisco Chronicle staff writer Bob Egelko contributed to this report.

Kimberly Veklerov is a San Francisco Chronicle staff writer. Email: kveklerov@sfchronicle.com Twitter: @kveklerov