A Muslim taxi driver refused to let a woman ride up front with him as her family piled into his yellow cab at Penn Station — later claiming that his religion forbids him from being that close to a female stranger.

But a city judge didn’t buy the Islam argument and socked the driver with a $350 fine for his discrimination.

Fellow Muslims on Friday said Tamsir Drammeh’s excuse was a stretch.

“There’s no such rule in Islam,” said the manager at his garage, J and I Maintenance Corp. in Boerum Hill, Brooklyn, who refused to give his name. “There’s no such thing.”

A driver at the garage added, “Maybe if she was drunk and wearing a skirt hiked up to here,” as he pointed to the tops of his thighs. “He wouldn’t have her in the front, but only if she is alone.”

Drammeh, 64, was at a taxi stand on Eighth Avenue when the family of four walked up. He popped the trunk from his seat so that the family could stow their luggage.

The husband and kids, 6 and 11, got into the back, and the mom went to the front passenger door, which Drammeh refused to unlock.

The woman asked whether there was a problem, and all Drammeh would say is that her husband could sit up front, but that she was not welcome.

The family snapped a photo of Drammeh’s medallion number and hailed a different cab.

‘That his religion did not allow him to sit next to a woman is not an acceptable defense…’

- Judge Laura Fieber

The wife filed a complaint alleging sex discrimination, and Drammeh lost the case twice — once in a regular city hearing and again on appeal.

At his hearing, the driver claimed that the woman was belligerent and cursed him out — and he said he still came around and reluctantly invited her to sit up front.

The hearing’s judge, Laura Fieber, told the cabby he needs to keep his religion to himself when serving the public.

“That his religion did not allow him to sit next to a woman is not an acceptable defense in an occupation that is operated to serve the public,” she wrote. “Of significance, respondent made it clear that the husband would be welcome in the front seat, while the wife/complainant would not be.”

The city fined Drammeh in September and also suspended him for one day. He still has an active hack license.

Hossein Kamaly, a Middle Eastern studies professor at Columbia University, said Muslims often make up their own interpretations of the legitimate laws of Islam.

“There are some Muslims who wouldn’t be comfortable with that and some who would,” he said. “He’s an older man and probably an immigrant, so it’s closer to the way that he was brought up.”