Xavier Becerra narrowly won confirmation Thursday to lead the Department of Health and Human Services, the agency pivotal to President Biden’s urgent goal of defeating the coronavirus pandemic and expanding access to health care.

Becerra, a congressman from Los Angeles for two dozen years and then California attorney general, squeaked by on a vote of 50 to 49, the closest margin for any of the Biden Cabinet members the Senate has confirmed so far.

He becomes the first Latino secretary of HHS, the largest federal department in terms of spending. The department includes agencies at the core of the federal response to the pandemic that has infected more than 29.6 million people in the United States and killed more than 535,000. They include the National Institutes of Health, the Centers for Disease Control and Prevention, the vaccine-approving Food and Drug Administration and the Centers for Medicare and Medicaid Services, which oversees the country’s vast public insurance programs.

Sen. Ron Wyden (D-Ore.), chairman of the Senate Finance Committee, which considered the nomination and ended in a tied vote, said that “after four years of going in reverse,” Becerra will make it “possible to go to drive and actually make progress for the American people, progress in terms of lowering the cost of health care.”

Sen. John Barrasso (R-Wyo.) countered that Becerra is “an aggressive culture warrior from the radical left,” who is “out of touch with the views of the American people.” Barrasso noted that, as state attorney general, Becerra sued the Trump administration more than 150 times over immigration, environmental and health policies.

“In this time of crisis, our secretary of health and human services may be the single most important member of the president’s Cabinet,” Barrasso said, contending that “the president has chosen a nominee — no public health experience, extremely partisan record.”

Sen. Susan Collins (Maine) was the only member of the GOP to vote for Becerra’s confirmation, along with a solid wall of Senate Democrats.

During his confirmation hearing last month before the Finance Committee, Becerra said, “The mission of HHS — to enhance the health and well-being of all Americans — is core to who I am.”

In keeping with Biden’s emphasis on portraying his administration’s top rung as diverse and having working-class roots like his own, Becerra told the senators his immigrant parents had insurance through his father’s laborers union, making his family more fortunate when he was a boy than many of their neighbors.

As a longtime member of the House Ways and Means Committee, Becerra testified, he worked on several major pieces of health-care legislation, including the Children’s Health Insurance Program created in the late 1990s and changes to the way Medicare is run and financed, as well as the Affordable Care Act.

He did not mention that he was a longtime advocate of a single-payer health-care system, akin to the Medicare-for-all proposals backed by several Democratic candidates in last year’s presidential election but rejected by Biden. Since being nominated, Becerra has renounced his previous support, echoing the president’s view that affordable insurance coverage should be widened by building upon the ACA.

Becerra, 63, became a lightning rod for conservatives immediately after Biden announced his selection in December.

Senate Republicans targeted his defense of abortion rights. They contended he is unqualified because he is not a physician, though few HHS secretaries have had medical training. And they denounced his previous advocacy of a larger government role in health insurance.

An undercurrent running through opposition to his nomination was Becerra’s leadership in recent years of a coalition of Democratic attorneys general fighting to preserve the ACA. Republicans, including President Donald Trump, have been seeking to overturn the 2010 law in a case now before the Supreme Court.

Sen. James M. Inhofe (R-Okla.) lambasted Becerra, saying he has “an appalling track record disrespecting the sanctity of life. . . . He has no shame when it comes to his pro-abortion beliefs.”

Inhofe also criticized Becerra’s support last year for California’s ban on indoor worship services as part of the state’s efforts to slow the coronavirus’s spread. And the senator criticized Becerra’s position that undocumented immigrants should be allowed public benefits, such as Medicaid.

Senate Majority Leader Charles E. Schumer (D-N.Y.) said Republicans’ arguments against Becerra “almost verge on the ridiculous.”

Schumer said Republicans challenging Becerra’s qualifications had embraced the nomination of Alex Azar as Trump’s second HHS secretary, though he was a pharmaceutical executive who also was an attorney and had no medical training.

In addition to working to tame the pandemic, which Biden has identified as the government’s job No. 1, Becerra will face many major decisions over whether to continue or reverse policies established by the Trump administration.

The Centers for Medicare and Medicaid Services has already announced it was rescinding a significant Medicaid policy of the Trump era that had allowed states to require some residents to hold a job or be preparing for work to qualify for the safety-net insurance program. HHS officials are reviewing other Trump-era Medicaid policies.

Another HHS agency, the Administration for Children and Families, oversees the nation’s policies regarding welfare and unaccompanied children coming across the country’s borders — a flash point during the Trump administration.

The CDC, the government’s public-health agency, has been working to regain its footing and scientific moorings after repeated intrusions into its advice to the public by the Trump White House. The agency has been involved in the largest mass vaccination campaign in U.S. history, to immunize the public against the coronavirus. And it is developing guidance on aspects of American life — and ongoing public safety measures — as research findings evolve for the virus and the vaccines’ effects.

The FDA is in the thick of decisions about coronavirus vaccines, developed in record time, as additional manufacturers, such as AstraZeneca, have devised them and tested their safety and effectiveness. The three vaccines being given to about 2 million Americans a day — by Pfizer-BioNTech, Moderna and Johnson & Johnson — are being allowed so far for emergency use and have not yet secured full FDA approval.

The health-care industry has been largely supportive of Becerra’s nomination, and some organizations issued the kind of positive statements Thursday typical for the arrival of an HHS secretary with whom they will need to work.

In Congress and as California attorney general, “Secretary Becerra exhibited an unceasing dedication to protecting the health and well-being of all Americans,” said Matt Eyles, president of America’s Health Insurance Plans, the insurers’ trade group.

And his confirmation was lauded by groups promoting reproductive rights.

“Becerra’s record fighting for high quality, equitable health care, including sexual and reproductive care, makes him the right person for the job at this critical time,” Alexis McGill Johnson, president of Planned Parenthood Federation of America, said in a statement.

However, Becerra almost certainly will continue to face hostility from social conservatives after his swearing-in, expected Friday.

Roger Severino, who led HHS’s Office for Civil Rights during the Trump administration and created a division to promote “conscience and religious freedom,” is building an “HHS Accountability Project” within the conservative Ethics and Public Policy Center.

While at HHS, Severino tangled directly with Becerra during his tenure starting in 2017 as attorney general of the nation’s most populous state, twice citing him in violation of federal laws for upholding California statutes involving abortion rights.

Severino said this week he believes those on the right might find common ground with Biden health officials on disability rights. But on matters of abortion and deference to religion, Severino said, “We will be watching.”