Oakland’s failed fight to keep coal shipments from passing through its waterfront cost the city more than $3.1 million in outside legal bills, according to records provided by the city attorney’s office.

The coal fight stemmed from a 2013 agreement between the city and local developer Phil Tagami allowing him to build a $250 million shipping terminal on the old Oakland Army Base next to the port.

Tagami, a former business partner of Gov. Jerry Brown, had assured local officials he had no intention of shipping the politically and environmentally incorrect coal through his facility, but the agreement with the city didn’t expressly prohibit it.

When Tagami subsequently secured a deal to move up to 10 million tons of Utah coal through the terminal each year, the plan drew strong protests from social justice and environmental activists — and the City Council voted to declare the coal shipments “a substantial danger to the people of Oakland.”

Tagami countered that the coal posed no health risk and sued the city.

Last week, U.S. District Judge Vince Chhabria said Oakland had failed to make a convincing argument that the coal was a health threat.

Mayor Libby Schaaf immediately insisted the battle to keep coal out of Oakland wasn’t over and pledged to “continue to fight this battle on all fronts.”

Councilwoman Rebecca Kaplan said she wouldn’t rule out a second try at proving the city’s health-related argument in court, but also said it’s time to sit down with Tagami and try for a negotiated settlement — something the mayor and city administrator had opposed.

“Libby strongly opposed settlement,” Kaplan said. “Folks said we would win, so it was not important to pursue settlement.”

Fellow Councilman Noel Gallo tells us Tagami approached him as recently as two weeks ago looking for help in getting the mayor and city administrator to the bargaining table. He said Tagami was mostly looking to “recoup” his investment in the bulk terminal — a figure Gallo said has been put as high as $71 million.

“He has been willing and open to settle ... but the city wasn’t willing to cooperate,” Gallo said.

Tagami declined to comment Friday, and a spokesman for Schaaf referred all questions to the city attorney’s office.

City attorney spokesman Alex Katz said only that “we are reviewing the (court) ruling and will discuss our options with the City Council.”

City Hall sources tell us the city could spend the next several years — and millions more dollars — battling the coal proposal in court, with an uncertain outcome. Or they could settle with Tagami, whose leverage over the city has now increased with the court ruling in his favor.

Either way, it’s certain to get a lot more costly for Oakland.

Civic issue: BART officials are planning to seek permission from the State Fire Marshal’s Office to shut down an entrance and walkway to the underground Civic Center Station that has become a haven for drug users.

“It’s ground zero for injection drug use,” said BART Director Bevan Dufty, whose San Francisco district includes the troubled station.

The proposed closure of the walkway under Market Street is the latest in a series of steps BART and city officials have undertaken in an effort to clean up San Francisco stations. Both Civic Center and 16th Street Mission stations have become magnets for the homeless and the mentally ill, and the sites of injection drug use in recent years.

The problem hit the boiling point recently when local TV stations aired videos showing people openly shooting up drugs in the Civic Center walkway. After seeing the embarrassing video on the news, Mayor Mark Farrell called a meeting with BART officials at City Hall that resulted in increased police patrols of the station.

When more video appeared a few days later showing little had changed, Dufty set up a makeshift “office” inside the station and called in the media to highlight the problem.

“Yes, it was meant to get attention, but I can’t tell you how many people came up and said, ‘Thanks for being here,’” Dufty said.

The Salvation Army was also on hand and took four homeless people to its detox and recovery program.

Dufty, a former San Francisco supervisor with an eye for publicity, has made a mini-crusade of cleaning up BART stations.

The first target was 16th Street Mission Station, where he began sweeping out the station once a week to highlight the need for a full-time janitor.

“It didn’t endear me to BART management,” Dufty said. “They thought I was grandstanding.”

He was. And as a result, BART assigned a full-time janitor and attendants to help keep the station’s elevators clean and safe.

For years, a combination of budget cuts, understaffing and concerns about targeting homeless people kept station upkeep and safety on the back burner at BART. But as ridership on off hours and weekends began to drop, the attitude has changed.

“A 4 percent drop might not sound like much, but for BART it’s Kryptonite,” Dufty said.

San Francisco Chronicle columnists Phillip Matier and Andrew Ross appear Sundays, Mondays and Wednesdays. Matier can be seen on the KPIX-TV morning and evening news. He can also be heard on KCBS radio Monday through Friday at 7:50 a.m. and 5:50 p.m. Got a tip? Call (415) 777-8815, or email matierandross@ sfchronicle.com. Twitter: @matierandross