AUSTIN, Tex. — A bill to restrict which bathroom transgender people can use in public buildings and schools died in the Texas Legislature on Tuesday evening, a rare defeat for social conservatives in a state they usually dominate.

The failure of the so-called bathroom bill at the end of a special legislative session was the second time in three months that the bill had fallen short, and it deepened the ideological discord within the Texas Republican Party. But it did not kill the issue entirely.

The Republican lieutenant governor, Dan Patrick, who pushed for the bill’s North Carolina-style restrictions on transgender bathroom use, virtually guaranteed that the issue would arise again in future legislative sessions. And it is still possible that Gov. Greg Abbott, who supported the bill, will recall lawmakers for a second special session to give the bill another chance at passage.

The Run-Up

The podcast that makes sense of the most delirious stretch of the 2016 campaign.

“You know why it’s going to be back next session? Because the people will demand it,” Mr. Patrick told reporters Tuesday night. “The issue is not going to go away.”

Opponents of the measure, including gay rights activists, corporate executives, transgender Texans and both Democratic and Republican lawmakers, hailed the bill’s demise in the special session as a significant achievement, even if it proves to be short-lived. The Legislature had previously failed to pass it during the regular session that ended in May.

“Defeating this discriminatory and dangerous legislation in Texas is a huge victory that will have an impact far beyond the Lone Star State,” Kasey Suffredini, the acting chief executive of Freedom for All Americans, a national gay rights and transgender rights group, said in a statement.

In the special session, conservative lawmakers passed a version of the bill in the Texas Senate, where Mr. Patrick presides, but the moderate Republicans who lead the Texas House never referred it to a House committee, so it was effectively dead on arrival in the chamber. Another version, written by a House lawmaker, was never given a hearing.

The bills would effectively have required transgender people to use bathrooms, locker rooms or showers corresponding with the sex listed on their birth certificates, not their gender identity, in government buildings and schools.

Interactive Feature | Sign Up for the Race/Related Newsletter Join a deep and provocative exploration of race with a diverse group of New York Times journalists.

The procedural moves in the House that killed the bathroom bill were led in large part by the House speaker, Joe Straus of San Antonio, one of the last Bush-style moderate Republicans to hold a prominent post in a state increasingly dominated by the far right. Mr. Straus and his allies in the House worried that enacting a bathroom bill would harm the state’s economy and its business-friendly image, in the same way that North Carolina was hit with boycotts and cancellations of sporting events and concerts after it passed a similar bill last year.

The debate over the bill illustrated the increasingly rightward tilt of Texas politics in recent years.

Mr. Patrick, Mr. Abbott and other Republican leaders pushed for the bill over the objections of many of the state’s corporate leaders and large companies. The state’s political and business leaders typically align on policy issues.

The willingness of social conservatives to break with business interests on the bill showed how far to the right they want to push Texas, while the success of moderate Republicans in killing the bill showed that they still retain some power to pull Texas back toward the center-right.

Business leaders played a pivotal role in persuading moderate Republicans to stand up to the lieutenant governor, the governor and other influential social conservatives. The Texas Association of Business mounted a large and well-financed lobbying campaign against the bathroom legislation, and released studies that forecast billions of dollars in economic losses if it were to pass. IBM took out full-page ads opposing the bill in major Texas newspapers, and corporate giants like American Airlines, AT&T and Texas Instruments warned Mr. Abbott in a letter that the bill “would seriously hurt the state’s ability” to attract jobs and investment.

“For me, having the business community weighing in as strongly as they did to say this would have a chilling effect on the business climate and opportunity in this state is a huge factor,” said Byron Cook, the Republican chairman of the House State Affairs Committee, who refused to hold a hearing on a House version of the bathroom bill during the special session.

Supporters of the bill warned that Mr. Straus, Mr. Cook and others who opposed the measure would pay a price in the 2018 Republican primaries. Grass-roots social conservative activists and voters hold tremendous sway in Texas’s low-turnout primary elections.

Jonathan M. Saenz, president of Texas Values Action, which helped lead the push for the bathroom bill, said that his organization would make the issue a top priority next year and that Mr. Cook and other opponents of the bill “are going to be vulnerable when it comes time for re-election.”

A spokesman for Mr. Abbott, Matt Hirsch, put it even more bluntly: “This is why we have elections.”

Mr. Cook defended his position, pointing out that his committee held a marathon hearing on the bill during the regular session that ended in May. “I think it’s incumbent on officeholders to do what’s right, period,” Mr. Cook said.

The governor convened the special session that began on July 18 and set the agenda for it. The bathroom bill was one of 20 items of business, most of them social conservative priorities that the Legislature failed to pass during the regular session. That regular session devolved into bitter intraparty squabbling toward the end, and the special session ended the same way Tuesday night.

The special session was originally expected to last 30 days and wrap up on Wednesday, but the House abruptly adjourned Tuesday night over a dispute with the Senate on a property tax bill. The Senate followed suit later in the evening.

In a radio interview on Wednesday, Mr. Abbott said he had not ruled out ordering a second special session for the property tax bill, one of his top priorities. If he does so, he could add the bathroom bill to the agenda.

“I’m disappointed that all 20 items that I put on the agenda did not receive the up-or-down vote that I wanted, but more important, that the constituents of these members deserved,” Mr. Abbott said in an interview on KTRH radio. He said the Legislature “had plenty of time to consider all of these items, and the voters of the state of Texas deserved to know where their legislators stood.”

Though only half of the governor’s agenda items were passed, Mr. Abbott’s supporters and aides called the session a success. “Our office believes this special session has produced a far better Texas than before,” said John Wittman, a spokesman for the governor.

But Mr. Abbott’s failure to get the Republican-dominated Legislature to enact his whole social conservative agenda has opened him up to a new round of criticism that he is strong in rhetoric but weak in influence.

“Like his tenure in office, Governor Greg Abbott’s first special session was bad for Texas,” State Representative Eddie Rodriguez, Democrat of Austin, said in a statement. “We’ve gone through this charade at a cost of over $1 million to Texas taxpayers, and we must not make the mistake of coming back for a second.”

Mr. Abbott and Mr. Patrick had strong words for Mr. Straus. The governor, in a series of radio interviews, accused Mr. Straus and the House of moving slowly on his agenda and “wasting time.” Mr. Patrick criticized Mr. Straus for adjourning the House early, a move that helped kill the property tax legislation.

Mr. Straus took a different tack, issuing a statement that refrained from any sharp criticism.

“We considered every idea carefully, listened to constituents and acted on a number of critical issues, such as helping retired teachers,” Mr. Straus said. “House members voted for new limits on property tax growth and significant school finance reforms, but in the short time available, we did not reach final agreement with the Senate on those issues.”