Republicans in the third-most-populous county in Texas voted overwhelmingly against the removal of one of their party leaders from his post Thursday.

The vote was not over qualifications or any misdeed by the party leader, Shahid Shafi, a surgeon and longtime Republican, who was appointed vice chairman of the Tarrant County Republican Party six months ago.

It was over whether Shafi’s Muslim faith disqualified him from the job. The vote came as Democrats had been heralding the arrival of the first two Muslim women in Congress last week.

“Religious liberty won tonight,” Darl Easton, the Republican Party’s county chairman, said after Shafi was supported, 139-49, in Thursday’s vote. “And while that makes a great day for the Republican Party of Tarrant County, that victory also serves notice that we have much work to do unifying our party.”

Shafi, who emigrated from Pakistan 29 years ago, sailed into his role in July, with a single dissenting vote. Since then, Texas Republicans have tried to smother the brush fire lit by Dorrie O’Brien, who cast the lone vote against him and who began to agitate for his removal soon afterward.

O’Brien was one of the 269 Republican representatives eligible to vote, each one representing a voting precinct in the county. On Thursday night, those precinct captains voted in a 2 1/2-hour executive session behind closed doors in a church.

Easton said the vote demonstrated the party’s allegiance to the Constitution and its prohibition of religious and racial discrimination.

“This vote reaffirms the commitment by a majority of Tarrant County Republicans to our core values and moral compass,” he said.

O’Brien had spent the past several months trying to persuade precinct chairs to oppose Shafi, and she was able to gain another 48 dissenters by Thursday night. One of them, Dale Atteberry, was upset with the results and quit after the vote.

“We don’t think he’s suitable as a practicing Muslim to be vice chair because he’d be the representative for ALL Republicans in Tarrant County, and not ALL Republicans in Tarrant County think Islam is safe or acceptable in the U.S., in Tarrant County, and in the TCGOP,” O’Brien wrote on Facebook in December.

This was not the first effort to block a practicing Muslim from a Republican leadership role in Texas. In 2016, a local precinct chair tried unsuccessfully to prevent another Pakistani-American from becoming a precinct chairman in Harris County, which encompasses Houston and is the fourth-largest county in the nation.

But this latest controversy brought out the biggest Republican luminaries in the state, and they offered resolute support for Shafi, 54, who became a citizen in 2009 and who has served as a City Council member in Southlake, Texas, since 2014.

“The promise of freedom of religion is guaranteed by the First Amendment in the Constitution; and Article 1, Section 4 of the Texas Constitution states that no religious test shall ever be required as a qualification to any office or public trust in this state,” Gov. Greg Abbott said this week in a statement.

Abbott was joined by Sen. Ted Cruz and George P. Bush, the state land commissioner and grandson of former President George Bush.

Tarrant County, whose biggest city is Fort Worth, has been solidly Republican. But in November, a majority of voters there backed the Democratic nominee for U.S. Senate, Beto O’Rourke, and other state Senate and House seats flipped to the Democrats.

Shafi declined to comment. But during the campaign to remove him, he reaffirmed his political beliefs and tried to swat away the attacks on himself and his faith.

“I fully support and believe in American Laws for American Courts,” he said on Facebook. “I support our Second Amendment rights unconditionally, and I believe in the sanctity of life from conception onwards. I believe in small government, lower taxes, individual responsibility, religious freedom, school choice, energy independence, rule of law and secure borders.”

Shafi said that he felt at home in the Republican Party. He recently told the Fort Worth Star-Telegram: “I have seen a lot of support from within the party; overwhelming support from elected officials, from rank-and-file members; from people within the county; from people outside the county but within the state. There has just been an outpouring of support.”

He blamed a few party members for causing the dissent and said that he was fighting for the higher principle of equality.

Across the nation, most Muslims — 66 percent — identify politically as Democrats. Thirteen percent call themselves Republicans, according to the Pew Research Center, and 20 percent say they are independent. Muslims comprise about 1 percent of the U.S. population, about 3.5 million people, but they are clustered in critical political states, like Michigan and Florida as well as larger states like California, Illinois and Texas.

In Texas, the executive director of the Tarrant County Republican Party said Thursday that his organization had received hundreds of phone calls and emails this week calling it racist. The official, Jeremy Bradford, said the party wanted Shafi to remain as vice chairman.

“Our elected officials support our party platform and our Constitution and we stand for religious freedom,” he said.

This article originally appeared in The New York Times.