BART may have found an easy answer to its massive fare-cheating problem: Bolt shut some of the swinging station doors that thousands of riders use to skirt the ticket gates.

But, as the transit agency prepared to quietly expand the successful scheme last month, San Francisco fire inspectors stepped in, The Chronicle has learned. They forced BART to reopen more than a dozen doors at downtown stations, citing a fire code violation.

Now BART is trying to find a way to shut the doors and still comply with the city fire marshal, while it continues working to stymie fare evaders, who probably cost the agency millions in revenue every year.

“What’s behind this is we know people are fare evading, and it’s extremely frustrating,” BART spokeswoman Alicia Trost said. “We want to show people we are doing everything we can to make sure we are getting every penny owed to us.”

BART estimates the number of people who don’t pay by comparing how many tickets enter its system versus the number that exit through its fare gates. Typically, BART’s data show 7,000 fewer exits every day, officials said.

While that number doesn’t account for scenarios where people don’t cheat, it provides insight into how widespread the fare-evasion problem is.

“We don’t have an exact number,” Trost said. “What we know is that fare evasions cost the district millions annually.”

Riders using wheelchairs, pushing baby strollers, or lugging bikes and other cumbersome items are allowed to use the swing gates to exit stations, but are still required to scan their tickets at the pay gates.

BART put its plan into action Nov. 2 when it quietly bolted shut 10 of 12 swinging metal exits at Embarcadero Station, while putting up signs reading, “No exit.”

For safety reasons, it “added an extra layer of ability to open the fare gates” by giving workers in its operations center the same power to spring the doors open during emergencies that station agents have, Trost said.

BART immediately saw results. On the first day the swing doors were locked, scores of would-be evaders banged into them before sheepishly heading out through the proper gate with a ticket or Clipper card, officials said.

BART data appear to show the plan was working. On that first day, Embarcadero Station showed 5,000 more people exited than the day before.

It’s unclear, though, whether that number was solely related to the bolted doors. Other downtown San Francisco stations without locked swing gates showed higher exit numbers that day as well, pointing to overall higher ridership, Trost said.

But for all of November, more than 2,000 additional people were shown to have exited at Embarcadero Station compared with November 2015.

The idea to lock the doors became so successful that on Nov. 14, BART began closing swing gates at Montgomery Station. But the next day, it got a notice of violation from the city fire marshal after officials said they received “numerous citizen complaints” about the locked doors.

“We contacted BART, and we advised them they had to restore the gates to the original function,” said Lt. Jonathan Baxter, a San Francisco Fire Department spokesman.

He said the problem, in general, is that the state fire code doesn’t allow public exits to be locked.

“Unless they can provide the marshal with an exit analysis that shows the gates are not required for egress — or a way to get out — they have to be rectified,” Baxter said.

On Dec. 9, BART unlocked all of its swing doors.

“They complied right away,” Baxter said. “Now they’re moving forward with a solution.”

Going forward, officials hope to create a way to pop open the swing gates in emergencies and redraft BART’s exit analysis to show the gates are not required for egress. If all goes well, the agency will reintroduce the plan at all its downtown San Francisco stations.

On a recent weekday afternoon — after The Chronicle learned about the program to lock the swing doors, which was never announced publicly — more than a dozen people were observed sneaking out of one end of Embarcadero Station in less than half an hour.

A middle-aged woman in black tights carrying a shopping bag carefully pushed through one gate on the station’s north end before zipping up the stairs onto Market Street. She was followed minutes later by a man walking a Chihuahua, a couple who appeared to be in their 20s, and a well-dressed older man who casually ambled out the door.

One teenage boy dipped out through the swing door, while his group of friends did the honest — and legal — thing and scanned their tickets.

None of the evaders would comment to The Chronicle, but honest, fare-paying riders had plenty to say.

“I see it every day,” 54-year-old Richmond resident Lenton Glasco said after scanning his ticket at Embarcadero Station. “I get frustrated because I work hard for my money.”

Nancy Sanders commutes to the city from Vallejo. She takes a ferry and gets on a train between the Embarcadero and Civic Center.

She usually takes less crowded Muni trains but often gets on BART, where she said she usually has to stand. Knowing that many of those riders on crowded trains don’t pay is bothersome, she said.

“Anything they do to improve the situation is good,” she said when told of the effort to lock the gates.

In November, voters approved a $3.5 billion bond measure to improve BART’s transit infrastructure, and officials know many citizens want accountability and for riders to pay their fair share.

So as BART re-evaluates its plan to close the downtown gates, members of its fare-evasion-prevention task force are devising other ways to crack down on railcar stowaways.

Engineers are improving fare gates by making them higher — and harder to vault over, raising barriers between stations’ free and pay areas, and stepping up enforcement with more cops writing tickets.

“We want to prevent fare evasion,” Trost said. “The idea is to recover costs we’re missing and show riders we understand and we’re not going to put up with it.”

Evan Sernoffsky is a San Francisco Chronicle staff writer. Email: esernoffsky@sfchronicle.com Twitter: @EvanSernoffsky