Over the opposition of Democrats and the loud protests at the Capitol this month, the Texas Legislature voted on Wednesday to approve a bill banning hormone and puberty blocking treatments, as well as surgeries for transgender children. The state is poised to become the largest state to ban transition medical care for minors.

The final version of the bill included a limited exemption for those transgender children who were already receiving medical treatment before the bill’s passage, though it also required those patients to “wean” themselves off the medications over an unspecified period of time.

The bill would prohibit a doctor from performing mastectomies or surgeries that would sterilize a child or remove otherwise healthy tissue or body parts, or from prescribing drugs that would induce transient or permanent infertility. It now heads to the governor’s desk.

The legislation was one of several proposals aimed at regulating the lives of transgender people being considered this year by the Republican-dominated Legislature: On Wednesday, the State House voted to advance a measure requiring athletes in public colleges to compete based on the sex inscribed on their birth certificate at the time of their birth.

The legislation, known as Senate Bill 14, was among the most volatile measures of the state’s every-two-year legislative session, drawing protests from transgender Texans and their supporters at the Capitol this month. State police arrested two people amid protests as the bill was being discussed in the Texas House.

Opponents in the House twice delayed votes on the bill on procedural grounds before it was ultimately passed and returned to the Senate, where it first passed last month. The Senate voted to concur with the House version and send it to the governor on Wednesday.

Even before the legislation passed, Texas officials had taken steps to try to prevent transgender children from accessing medical transition care. Last year, Gov. Greg Abbott, a Republican, directed the state’s child protective agency to investigate parents for child abuse if their children received such treatment. Some Texas families fled the state as a result, even as the investigations were being challenged in court.

At least 14 other states have enacted bans or restrictions on medical treatments for transgender children. Texas would be the largest state to do so. According to estimates from the Williams Institute, a research center that reports on the demographics of the L.G.B.T.Q. community, nearly 30,000 transgender children between 13 and 17 live in Texas, making up about 1 percent of Texans in that age group.

The bans are part of a national effort by Republican elected leaders to restrict medical care for transgender children, discussions on gender in schools, and drag performances. Gov. Ron DeSantis of Florida signed a bill on Wednesday that bans hormone treatments and gender-transition care for minors, and penalizes doctors who violate the law with up to five years in prison.

Supporters of the Texas legislation have called the treatments “mutilation.” Opponents condemned the measure as a politicized assault on the transgender community that would prevent people from receiving care needed to address gender dysphoria. The treatments have been recommended by the American Academy of Pediatrics.

The bill heads to the governor’s desk. His office declined to comment on the legislation this week. It would go into effect on Sept. 1.

According to the bill, minors who are already receiving prescribed medical treatment would be able “over a period of time and in a manner that is safe and medically appropriate” to “wean” themselves off the medication.

But it was not clear whether doctors would feel comfortable continuing to offer that care. The bill gives enforcement authority to the Texas attorney general, Ken Paxton. Even before its passage, Mr. Paxton had already begun inquiries for “potential illegal activity” into at least one medical provider over gender-transition treatments.

After Mr. Paxton began looking into the provider, Dell Children’s Medical Center in Austin, the center said that doctors who treat transgender children would no longer be working there.