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.

“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.”