Biden has selected Xavier Becerra as his nominee for secretary of health and human services.

President-elect Joseph R. Biden Jr. has selected Xavier Becerra, a former congressman who is now the Democratic attorney general of California, as his nominee for secretary of health and human services, ending a politically delicate search that brought complaints from the Congressional Hispanic Caucus about a lack of Latinos in the incoming cabinet.

Mr. Becerra became Mr. Biden’s clear choice only over the past few days, according to people familiar with the transition’s deliberations, and was a surprise. He has carved out a profile more on the issues of criminal justice, immigration and tax policy, and he was long thought to be a candidate for attorney general.

But as attorney general in California, he led legal efforts on health care, including leading 20 states and the District of Columbia in a campaign to protect the Affordable Care Act from being dismantled by Republican attorneys general. He has also been a leading voice in the Democratic Party for women’s health.

If confirmed, he will immediately face a daunting task in leading the department at a critical moment during a pandemic that has killed more than 281,000 people in the United States — and one that has taken a particularly devastating toll on people of color.

Mr. Becerra, 62, served 12 terms in Congress, representing Los Angeles, before becoming the attorney general of his home state in 2017. He is the first Latino to hold that office, and while in Congress he was the first Latino to serve as a member of the Ways and Means Committee. He also led the House Democratic Caucus, which gave him a powerful leadership post.

Dr. Rochelle Walensky, the chief of infectious diseases at Massachusetts General Hospital, will be tapped to lead the Centers for Disease Control and Prevention, according to a person familiar with Mr. Biden’s deliberations. Ms. Walensky, whose selection was reported earlier by Politico, will replace Dr. Robert R. Redfield as the leader of the scientific agency at the forefront of the nation’s pandemic response.