The first time Shahid Shafi ran for a seat on the city council in Southlake, Texas, in 2011, advisers assured him a Muslim in post-9/11 America who spoke with an accent and immigrated from Pakistan would never win an election in Texas.

It’s a story that Shafi, a Republican trauma surgeon, likes to tell because he didn’t believe them. He won the Southlake City Council seat on his second try, in 2014, has since served as a delegate to multiple Texas GOP conventions and, in July, was appointed vice chairman of the Tarrant County Republican Party, located in Fort Worth.

But that’s when his religion somehow became a problem again – in the eyes of some Republican colleagues.

Shafi hadn’t held the position in the North Texas county for more than a couple days before a precinct chairwoman urged Darl Easton, chairman of the Tarrant County Republican Party, to “reconsider” appointing Shafi to a leadership role, a request that was soon echoed by several other precinct chairs.

“The only reason she had was because he was a Muslim,” Easton told The Washington Post. “That was the only reason she gave.”

Since then, that precinct chairwoman, Dorrie O’Brien, and a small group of her supporters have put forth a formal motion to remove Shafi as vice chairman because of his religion, a motion that is slated for a vote on Jan. 10. To Easton, who opposes the measure, the move is an embarrassment to the Republican Party. And to Shafi, it amounts to exactly what he believed didn’t exist in the United States when he arrived here 28 years ago: a religious test.

Over the past week, the movement to oust Shafi has drawn loud condemnation from Texas GOP leaders, including Land Commissioner George P. Bush and House Speaker Joe Straus. On Saturday, the Texas GOP Executive Committee passed a formal resolution reaffirming the GOP’s commitment to religious freedom and seeking to distance the party from xenophobia they fear the motion against Shafi may embolden. In Texas, it would not be the first time Republicans have tried to block Muslims from participating in GOP leadership roles. A Houston City Council staffer attempted, unsuccessfully, to block a Republican Harris County precinct chair in 2016.

“Let’s show everybody, this is the Republican Party of Texas. We are not the party of bigots,” said J.T. Edwards, a member of the State Republican Executive Committee, on Saturday while urging support for the resolution, the Austin American-Statesman reported.

O’Brien, who declined to speak with The Post, has publicly asserted that Shafi promotes Sharia law and is affiliated with terrorist groups while offering no evidence other than that he is a mosque-attending Muslim. In lengthy tirades on Facebook reviewed by The Post, she has accused Shafi of being a “fake Republican” who perhaps became one at the urging of the Muslim Brotherhood so that he could infiltrate the party – again, without any evidence.

“This is, unfortunately, not the first time that people or my political opponents have tried to use my religion against me to distract the voters,” Shafi, who has fiercely denied O’Brien’s assertions, told The Post, “and unfortunately, I don’t think it will be the last either.”

The pleas from state leaders to stop the campaign to remove Shafi appear to have had little bearing on those supporting it. Emails first obtained by the Fort Worth Star-Telegram showed O’Brien and fellow Tarrant County Precinct Chair Dale Attebery inviting John Guandolo, who is described by the Southern Poverty Law Center as an “anti-Muslim activist,” to give a Dec. 29 “training” session on the dangers of Sharia law. A former FBI agent, Guandolo has described all Muslims as terrorists during these presentations and has said he believes American political leaders “should be Christians.”

Attebery, in an email obtained by the Star-Telegram, said the reason for the class was “because we need to know the truth before Jan. 10,” the date of the vote on Shafi. When asked about the event, Easton stressed that while individual members within the Tarrant County GOP organized it, the party itself does not endorse the session.

“They promote it as, ‘We need to be extremely vigilant of Muslims in this country, particularly the ones running for political office… because they’ll take over and start implementing aspects of Sharia law that may be counter to U.S. law,’” he said. Easton said he does not expect such an event to sway his support for Shafi, and believes most precinct chairs will support him as well.

The false generalizations about his religion, Shafi said, have been disheartening and offensive. Born in India but raised in Pakistan, Shafi came to the United States in 1990 to finish his medical degree and surgical residencies before becoming a naturalized citizen in 2009. He joined the Republican Party as a firm believer in small government, having experienced firsthand the oppressive overreach of Pakistan’s leaders. He saw public office as merely an extension of his mission as a surgeon, he said, with the difference being the opportunity to help hundreds or thousands rather than one patient at a time.

“This is my way of giving back to the community that has given me so much,” he said.

On Saturday, he traveled to the state GOP meeting so that he could be there to answer any questions from those voting on the religious freedom resolution. He was delighted, he said, that he didn’t have to try to convince them that he was just a regular Republican, free of terrorist ties and focused on lowering property taxes and improving school safety.

They voted 63-0 to pass the resolution – in turn, reaffirming Shafi’s belief in the party, he said.

“I’m not sure if I’ll be able to speak fully without breaking down,” Shafi told the room, the American-Statesman reported.

He revealed that “there were moments of doubt in my mind” over the past six months, as he feared whether his own local party would really oust him. The easiest thing he could have done, he told The Post, was resign.

But he didn’t want to, believing it would signal a loss for religious freedom.

“The reason I have stayed on is because the issue before the party is not about who the vice chair should be. It’s much more fundamental than that,” Shafi said. “It is about religious freedom, and if we are going to have a test of religion in the party, where will we stop? If Muslim Americans are not welcome in in the GOP, who will be excluded next?”