SALT LAKE CITY — The U.S. Senate confirmed the son of a former Utah Republican congressman as a federal judge Wednesday, despite objections from Democrats over his defending a same-sex marriage ban in California and his arguments that a gay judge in the case should have removed himself.

Utah Sens. Mike Lee and Mitt Romney joined the Republican majority in approving Howard C. Nielson Jr., 51-47. One Republican, Maine Sen. Susan Collins, voted against him.

"It was an honor to help confirm Judge Nielson to the U.S. District Court for the District of Utah. He is an extremely qualified nominee and will serve the court with honor and integrity," Lee and Romney said in a joint statement.

Nielson, the son of former Utah GOP Congressman Howard C. Nielson, was a partner at Cooper and Kirk, a law firm in Washington, D.C. A constitutional law expert, he has worked in the U.S. Department of Justice as counsel to the attorney general and as deputy assistant attorney general. Earlier in his career, he served as a law clerk to U.S. Supreme Court Justice Anthony Kennedy.

Former Sen. Orrin Hatch, R-Utah, called Nielson a "first-rate talent" with broad experience and a commitment to the rule of law when President Donald Trump first nominated him in September 2017.

"He has sterling credentials and a solid reputation in the legal community," Hatch said of Nielson, who earned an undergraduate degree from BYU and law degree from the University of Chicago.

But Nielson's confirmation wasn't without controversy. Democrats, LGBTQ advocates and gun violence prevention groups were among those opposing his confirmation.

On Tuesday, 59 House Democrats sent a letter to Senate Majority Leader Mitch McConnell, R-Ky., and Senate Minority Leader Chuck Schumer, D-N.Y., urging them to reject Nielson’s nomination.

“Howard Nielson has spent his legal career opposing equality,” Rep. A. Donald McEachin, D-Va., who organized the letter, said in a statement. “He has made baseless and profoundly offensive arguments in court against the LGBTQ community. We cannot afford to confirm Mr. Nielson, another problematic candidate for a lifetime appointment, who may well use his position on the bench to erode important civil rights protections.”

Democrats grilled Nielson over his role in California's Proposition 8 case in a Senate Judiciary Committee hearing. After a federal court ruled in 2010 that Proposition 8 violated the Constitution, Nielson argued that Judge Vaughn Walker should have recused himself because he didn't disclose that he was gay.

“If you say a judge in a same-sex relationship shouldn’t be able to oversee a case on LGBT rights, then do you think African-American judges should have to recuse themselves from civil rights cases?” Sen. Amy Klobuchar, D-Minn., asked last year, according to HuffPost. “Or women can’t hear sexual harassment cases?”

Nielson said that the positions he has taken in litigation “are those of my clients,” not his own. He said he was “a junior member of a legal team” in the Proposition 8 case and the lead counsel ultimately made the decisions on what arguments to advance.

In a written response to questions from Sen. Dianne Feinstein, D-Calif., after a committee hearing last year, Nielson said of the U.S. Supreme Court's ruling on gay marriage that he would "faithfully follow that decision and will not seek to undermine it."

Hatch defended Nielson's involvement in the Proposition 8 case in the hearing last year.

“He doesn’t have a bias in his heart. He was part of a legal team that defends the constitutionality of Prop. 8," he said. "He should not be condemned for having worked at that level.”

Nielson cleared the Senate Judiciary Committee after Trump nominated him in 2017, but Sen. Tammy Duckworth, D-Ill., put a hold on his nomination in March 2018, blocking it from a floor vote. Trump renominated Nielson in January and the committee narrowly approved him in February.

Sarah Warbelow, Human Rights Coalition legal director, urged the Senate to reject his nomination, calling it another attack on LGBTQ people by the Trump administration.

"Nielson has a long track record of hostility and discrimination toward the LGBTQ community," she said in a statement.

The San Francisco-based Giffords Law Center to Prevent Gun Violence condemned the confirmation.

“The federal bench in Utah is no place for a jurist who has taken his marching orders from the gun lobby. But that’s exactly where a Washington, D.C., lawyer who spent his career advocating a radical view of the Second Amendment is headed," Robyn Thomas, executive director, said in statement.

Nielson represented the National Rifle Association in unsuccessfully challenging restrictions on gun ownership for people under 21.

In his written response, Nielson said his clients took the position that specific restrictions on 18- to 20-year-olds buying and carrying guns were unconstitutional.

"My clients did not argue that the Second Amendment prevents all restrictions on gun ownership by such adults, nor did they challenge any laws restricting gun ownership by children under the age of 18," he wrote.