Two decades ago, Judge O’Connor — a native Houstonian who is married and has two daughters — was a Dallas-area federal prosecutor in his 30s. He had climbed up the legal ladder after trying local criminal cases as an assistant district attorney in Tarrant County, which includes part of Fort Worth. But his political and legal orbit changed in 2003.

He was tapped by the Justice Department to serve in Washington as counsel to the Senate Judiciary Committee, advising the Republican chairman at the time, Senator Orrin Hatch of Utah, and drafting legislation on terrorism and sentencing reform. He provided behind-the-scenes legal guidance, and impressed the Republican ranks of senators, including the two who represented Texas at the time, John Cornyn and Kay Bailey Hutchison.

A few years later, in June 2007, few were surprised when Mr. Bush nominated him to become a federal judge in the Northern District of Texas. He was unanimously confirmed by the Senate that November.

In one of his first major rulings, in 2008, Judge O’Connor dismissed a voting-rights lawsuit against the city of Farmers Branch, Tex., in which Hispanic residents claimed that the at-large system for City Council seats diluted the voting strength of minorities.

In August 2016, he blocked the Obama administration from enforcing guidelines intended to strengthen transgender rights. The administration had issued a letter to public schools stating that transgender students should be free to use bathrooms and locker rooms that match their gender identities, and that schools that refused to comply could lose federal funds. A Republican coalition of states, led by Texas, sued the administration, saying the administration overstepped its authority, and Judge O’Connor agreed.

Just a few months after that ruling, the judge halted another Obama administration effort to protect transgender rights. Texas and other Republican-led states had filed a suit challenging rules that would ban doctors and hospitals from discriminating against transgender people. Social conservatives said the rules would force some doctors to act against their religious beliefs. Judge O’Connor agreed, finding that the rules likely violated the Religious Freedom Restoration Act.

Conservatives have also been disappointed by some of his rulings, including one on immigration, a realm in which Democrats have often scored victories by turning to federal judges.