The Senate on Tuesday confirmed Dr. Monica M. Bertagnolli, a cancer surgeon who currently leads the National Cancer Institute, as the next director of the National Institutes of Health, overriding the objections of Senator Bernie Sanders of Vermont, the chairman of the Senate health committee.

The vote was 62 to 36, with Mr. Sanders voting no. In a statement last month, he said that while Dr. Bertagnolli was an “intelligent and caring person,” he would vote against her because she “has not convinced me that she is prepared to take on the greed and power of the drug companies and health care industry.”

Dr. Bertagnolli will become only the second woman to lead the N.I.H. on a permanent basis, after Dr. Bernadine P. Healy, who served under President George H.W. Bush. She will take over an agency that has been the target of political attacks by Republicans, who have accused its scientists of intentionally downplaying the possibility that Covid-19 was the result of a laboratory leak.

“I think no one wants to know what the true origin of the last Covid pandemic was more than the biomedical research community,” Dr. Bertagnolli told Senator Bill Cassidy of Louisiana, the top Republican on the health committee, during her confirmation hearing last month.

“And how will you accomplish that?” asked Mr. Cassidy, who is a medical doctor. Dr. Bertagnolli promised she would make any data on the subject “available, public and accountable to the American people.”

President Biden announced in May that he would nominate Dr. Bertagnolli to lead the N.I.H., the world’s premier medical research agency, which has an annual budget of more than $47 billion and occupies a sprawling campus in Bethesda, Md. It has been without a permanent director since Dr. Francis S. Collins stepped down nearly two years ago.

But in an unusual twist, Mr. Sanders, an independent who caucuses with the Democrats, held up Dr. Bertagnolli’s confirmation hearing for months in an effort to prod Mr. Biden to take more aggressive action to lower drug prices.

The stalemate finally ended in September, after the Department of Health and Human Services announced a $326 million contract with Regeneron to develop a new monoclonal antibody treatment for Covid-19. The deal stipulated that if the drug comes to market, its list price must be equal to or lower than the price in other major countries — a provision that prompted Mr. Sanders to announce he would schedule a hearing for Dr. Bertagnolli.

The hearing went well for Dr. Bertagnolli, who grew up on a ranch in southwestern Wyoming and was introduced to the committee by a Republican from that state, Senator John Barrasso. He lauded her as someone who understands rural America and said he had been chatting up her neighbors.

“They speak of her grit, her endurance and her determination,” Mr. Barrasso, who is a medical doctor, said, adding, “Her commitment to the land and the livestock speaks volumes about her character and her courage.”

Dr. Bertagnolli is also a cancer patient. She announced late last year that she had been diagnosed with breast cancer. She told the committee that she had completed her treatment and that her prognosis “is excellent.”

“I also had access to outstanding care, knowing full well that not every patient has that same chance,” she said. “Most importantly, every treatment I received was supported by N.I.H.-funded research.”