On her first day as director of the Centers for Disease Control and Prevention in January, Dr. Rochelle Walensky ordered a review of all Covid-related guidance on the agency’s website. Some of its advice had been twisted by the Trump administration, and her message was clear: The C.D.C. would no longer bend to political meddling.

Four months later, Dr. Walensky announced that vaccinated people could stop wearing masks in most settings. The recommendation startled not just the White House but also state and local leaders, prompting criticism that she had failed to prepare Americans for the agency’s latest about-face during the pandemic.

The two announcements captured the challenge that will define Dr. Walensky’s tenure at the C.D.C.: restoring an agency once renowned as the world leader in public health but whose reputation has been battered by political interference, even as the country transitions out of a pandemic that has left nearly 600,000 Americans dead.

President Biden had promised that the C.D.C. director he chose would be free to make scientifically grounded decisions without interference from politicians. Dr. Walensky, a widely respected infectious disease expert known for her battles with drug companies over prohibitive prices, seemed ideally suited.

Dr. Walensky’s appointment instantly made her one of the most influential women in the nation, and was greeted with enthusiasm by public health experts and C.D.C. staff members. But that enthusiasm has been tempered by occasional missteps in communications, an aspect of the job that is more important and challenging than it has ever been.

“Rochelle at baseline is an excellent communicator, but I think in a situation this fraught — politically, operationally and how quickly the science moves — you’re going to make mistakes,” said Dr. Celine Gounder, a former adviser to Mr. Biden’s team on Covid-19. “The question is, how does she acknowledge those and learn from those and move forward from there?”

Dr. Walensky, right, with Dr. Anthony Fauci, the Biden administration’s  pandemic adviser, left, and Dr. David Kessler of Operation Warp Speed, at a House subcommittee meeting in April.
Amr Alfiky/The New York Times

Dr. Gounder, who has known Dr. Walensky since 2004 and considers her a friend, said Dr. Walensky was still the best person she could think of to lead the C.D.C.

The C.D.C. floundered at the beginning of the pandemic, pilloried for its botched coronavirus test and antiquated data systems. Its advice on masking, asymptomatic spread of the virus and the threat indoors was muddled. By late 2020, reports that the Trump administration had rewritten recommendations purported to be from agency experts further damaged public trust.

Dr. Anthony S. Fauci, the administration’s lead adviser on the pandemic, defended Dr. Walensky’s track record and said he had full confidence in her ability to lead the C.D.C. and the country out of the pandemic. The job, he noted, has a steep learning curve.

“Give her a little time,” he added. “By the end of one year, everybody’s going to be raving about her. I guarantee it.”

Stan Grossfeld/The Boston Globe, via Getty Images

When the pandemic began, Dr. Walensky, 52, was chief of the infectious diseases division at Massachusetts General Hospital. She ordered the hospital staff to wear masks before it became the national norm, and advised the mayor of her town and the governor on testing and prevention of Covid-19.

Scenes from Mass General were still fresh in her mind when she arrived at the C.D.C. “I came directly from a hospital that had a morgue sitting outside,” she said in an interview. Even apart from the fact that she is only the third woman to lead the agency, “I’m a different kind of C.D.C. director than my previous 18 predecessors, and sort of a different kind of character in public health.”

Born Rochelle Bersoff, Dr. Walensky grew up in Potomac, Md. Her father, Edward Bersoff, was a mathematician and engineer at NASA; her mother, Carol Bersoff-Bernstein, was an executive at a technology company. Her sister, Dr. Susan Bersoff-Matcha, is a deputy director at the Food and Drug Administration.

In the mid-1990s, as a medical student and resident at Johns Hopkins University, Dr. Walensky saw firsthand the impact of AIDS, which became the focus of her research.

She met her husband, Dr. Loren Walensky, now a pediatric oncologist at Brigham and Women’s Hospital in Boston, in her first year at the university. She was six feet tall, he was 5-foot-8 — and “she just caught my eye,” he recalled. They were both Jewish, and shared a deep interest in medicine and music — she played the flute and he was a classical pianist. They married in 1995 and have three sons.

Dr. Walensky joined the faculty of Harvard University in 2001, where she worked on health policy for infectious diseases, particularly H.I.V. She gained a reputation as a rigorous researcher and a generous mentor, particularly to young women.

In 2017, she became chief of infectious diseases at M.G.H., the first woman and the third person to hold the job in 70 years. She had a warm, empathetic leadership style, said Dr. Kenneth Freedberg, an H.I.V. expert at the hospital who was first her mentor, then a collaborator. Eventually, she became his boss.

Hilary Swift for The New York Times

For her birthday a few years ago, her team at the hospital came to work dressed like her — “wearing black, or white, or black-and-white,” Dr. Freedberg said. It wasn’t until lunchtime, when everyone took out a yogurt, a root beer and a little bag of pretzels, her standard lunch, that she noticed.

Despite a grueling workload of patient care and research, Dr. Walensky made it to her sons’ piano concerts, karate tournaments and half marathons, according to her husband. The Walenskys decided early on that they would not work evenings or weekends, would be home for dinner every day, and take laptop-free vacations whenever their children were off school.

Dr. Walensky was known as a tough-minded advocate for people with AIDS. She tussled with pharmaceutical companies to lower prices for H.I.V. treatments. She called out the drug company Gilead’s pricing of its preventive therapy for H.I.V. and the exclusion of women from its clinical trials as “unacceptable.”

In 2019, she testified before Congress about the prohibitive cost of preventive therapy and treatments for H.I.V. and made similar arguments about the pricing of Gilead’s Covid drug remdesivir.

“I literally cried the night that I found out that Rochelle was going to be C.D.C. director — in happiness, in joy,” said James Krellenstein, executive director of the advocacy group PrEP4All Collaboration. “She is absolutely fearless in doing what is the correct thing, with zero concern for the political ramifications for herself.”

Pete Marovich for The New York Times

These days, she spends the week in Atlanta, waking up at 5:30 a.m. and working until 11 p.m. But she still eats dinners with her family on Zoom and travels to Massachusetts every weekend. “This is a working mom who’s always been working her tail off,” her husband said.

Dr. Walensky was not on the Biden’s administration’s initial list of candidates for C.D.C. director. It was Dr. Fauci, who had known and admired her work on H.I.V., who recommended her. Her leadership of the C.D.C. is demonstrably different from that of her predecessor, Dr. Robert R. Redfield. Under him, the agency quietly made changes to its guidance, sometimes dictated by the Trump administration, with no public announcement.

C.D.C. scientists are now routinely involved in conversations with the White House, where previously they were sidelined and silenced. And where Dr. Redfield was reticent, Dr. Walensky has often taken a surprisingly direct approach.

During a news briefing on March 29, as infections began to rise again, she looked into the camera and, in a voice quavering with emotion, pleaded with Americans not to stop taking precautions against the coronavirus.

“I’m going to pause here, I’m going to lose the script and I’m going to reflect on the recurring feeling I have of impending doom,” she said, her eyes glistening with tears. “We have so much to look forward to, so much promise and potential of where we are and so much reason for hope. But right now I’m scared.”

Her impassioned speech startled many people, perhaps none more than her husband. “She’s not a crier — if anything, I get choked up much more easily than she does,” he said. Her openness signaled her “genuine anguish” about the state of the pandemic, he added. “She deeply felt the weight of a half a million dead.”

The day of her urgent plea, she appeared on MSNBC’s “The Rachel Maddow Show,” where she said vaccinated people “do not carry the virus” — an overly optimistic statement that the C.D.C. had to walk back. Later that week, new guidance from the agency said that vaccinated people could safely travel, but Dr. Walensky added that the agency did not actually want them to travel at all, a stance that left some Americans perplexed.

The most recent instance, when Dr. Walensky announced that vaccinated people could go mask-free indoors, was supported by the latest research, scientists said. But many felt the agency had rushed the decision to end mask use without considering parts of the country where infections were still high, and without grasping the mistrust and culture clashes the new advice would engender.

“C.D.C. got the medical and epidemiological science right, but what they did not get right was the behavioral science, the communications and working collaboratively with other stakeholders,” Dr. Gounder said. “That was a big oversight.”

Data since the announcement seem to have proved Dr. Walensky correct: Infections are still declining, even as much of the country reopens at a vigorous pace. And as promised, the agency has set about issuing more practical masking guidance regarding settings like summer camps (mostly no) and public transportation (yes).

Dr. Walensky and the C.D.C. declined to comment on how the mask recommendations were handled. But Dr. Fauci said that he believed some small missteps were inevitable, and that Dr. Walensky was a quick study.

“Retrospectively, when you look at the negative reaction of so many people, so many organizations, you have to come to the conclusion that it could have been done better,” he said. “There’ll be a lesson learned here.”

Within the C.D.C., many scientists were relieved to have a leader who put science above politics. In interviews, several said the morale had drastically improved.

But the confusing communications rattled a few, turning optimism into “uncertainty and disappointment,” one senior C.D.C. scientist, who asked not to be identified because he was not authorized to speak publicly, said in April. “The ground is not nearly as stable as we thought it would be.”

Nathan Howard/Getty Images

The C.D.C. is a large and lumbering agency, bogged down by bureaucracy and hampered by what some experts describe as an overly cautious approach.

Under unrelenting pressure from the pandemic and the Trump administration, the atmosphere inside the agency devolved last year into ugly rivalries and turf wars, according to several staff scientists. Some felt betrayed by agency leaders who did not speak out publicly against the political interference.

The recent exits of two high-ranking agency officials within the C.D.C. — Dr. Anne Schuchat, the deputy director, and Dr. Nancy Messonnier, who led the agency’s infectious disease center — have led to speculation about continuing unrest within the agency.

But veterans in public health said such changes are expected after a leadership change and have occurred before. In an interview last month, Dr. Schuchat said she had come to admire and like Dr. Walensky: “This is a really tough leadership job, and I think she’s absolutely the right person for it.”

Covid has taken up nearly all of Dr. Walensky’s attention, but she has a long list of ambitious goals for the agency post-pandemic, including modernizing the nation’s public health infrastructure, addressing the health impact of climate change and managing what she called the “collateral damage” of the pandemic.

Pool photo by Greg Nash

That includes 11 million delayed pediatric vaccinations; widespread mental health problems; an uptick in opioid overdoses; and lapses in control of high blood pressure, cancer and H.I.V. Dr. Walensky also has her eye trained on racial equity in health care within the ranks of C.D.C. itself. An overwhelming majority of its scientists, and particularly those in management positions, are white.

Last summer, after protests over the death of George Floyd, more than 1,200 C.D.C. employees called on then-director Dr. Redfield to address “ongoing and recurring acts of racism and discrimination” against Black staff members and outlined a seven-point plan.

Dr. Redfield did not respond, and later in the year the agency suspended diversity training programs following an executive order from the Trump administration.

At her first all-hands meeting, Dr. Walensky startled the staff when she spoke emphatically about measures to increase diversity and inclusion in the agency’s work and in its ranks. She reinstated diversity training, and has promoted two Black scientists into management positions.

Covid remains her focus for now, and the flawed communications in recent weeks suggest that she is still finding her way. But in a recent interview, she was unapologetic about the rapid shifts in C.D.C. guidance or in her tone: The virus’s hold on the country is loosening, but large parts of the population remain unvaccinated and the pandemic is not yet over.

“There are two things happening at the same time,” she said. “It’s my responsibility to tell both of those stories.”