Treasury Secretary Janet L. Yellen defended the Biden administration’s economic agenda on Thursday, drawing sharp contrasts with the policies of the Trump administration as President Biden begins to make the general election argument that he has been a stronger steward of the economy than his predecessor.

The comments from Ms. Yellen came after new data released on Thursday bolstered that message: The United States economy grew at a healthy clip over the past year, surpassing 3 percent and defying expectations of a recession. The strong numbers coincided with an effort by the White House to amplify the president’s economic record and dispatch his top economic advisers around the country to make the case that his strategy is working.

Biden administration officials are trying to convince a skeptical public that, while they may feel pessimistic about the economy, its performance is delivering gains to average Americans. Officials are expected to spend the coming months highlighting the investments that Mr. Biden has directed toward infrastructure, domestic manufacturing and clean energy projects.

In a speech at the Economic Club of Chicago, Ms. Yellen argued that the Biden administration had successfully navigated challenging headwinds caused by the pandemic and led a recovery that has outpaced those in the rest of the world. She also suggested that the Biden administration needed more time to tackle affordability issues, such as improving access to child care and housing.

“Our economic agenda is far from finished,” Ms. Yellen said.

The Treasury secretary also took the rare step of directly criticizing the policies of Mr. Biden’s predecessor and likely opponent, former President Donald J. Trump. Pointing to Mr. Trump’s repeated pledges to rebuild America’s roads and bridges, she recalled how those promises went unfulfilled.

“Our country’s infrastructure has been deteriorating for decades,” Ms. Yellen said. “In the Trump administration, the idea of doing anything to fix it was a punchline.”

Ms. Yellen also assailed Mr. Trump’s tax cuts, castigating him for enacting a 2017 tax law that she said enriched corporations, increased America’s budget deficit and did little to make the economy stronger.

“Past measures like the Trump administration’s Tax Cuts and Jobs Act increased the deficit by $2 trillion while doing little to spur investment,” Ms. Yellen said.

As a candidate, Mr. Trump has called for extending the tax cuts that are scheduled to expire next year and imposing more tariffs on imports. Under Mr. Trump, the United States imposed tariffs on more than $300 billion of Chinese imports.

Treasury secretaries tend to avoid wading into politics, but Ms. Yellen told reporters ahead of her speech that she believed it was important to lay out the policy differences between the Trump and Biden administrations.

“I’m not getting involved in politics,” Ms. Yellen said. “But certainly tax policy is something that I’m deeply involved in and broad economic policy, and explaining to Americans what the strategy is and why it’s the right one, and why cutting taxes for the rich and hoping that the benefits trickle down, broadly, is not the right strategy.”

Ms. Yellen’s speech came as Mr. Biden traveled to Wisconsin to unveil approximately $5 billion of infrastructure investments in a crucial swing state.

It remains unclear whether the administration’s efforts will break through to voters, many of whom continue to give Mr. Biden poor marks on the economy. Although inflation has been easing, Americans are still coping with prices that are much higher than they were before the pandemic. Mr. Biden has been bearing the blame for that, and in a November New York Times/Siena College poll of voters in six battleground states, 62 percent of voters who supported Mr. Biden in 2020 indicated that they thought the economy is only “fair” or “poor.”

Elevated interest rates have made housing more expensive and the labor market is expected to tighten this year as the economy slows. Economists are also watching for more disruptions in energy markets, as the wars in Ukraine and Gaza continue to threaten trade routes.

Ms. Yellen acknowledged that while inflation is moderating, more needs to be done to bring down costs. She said that the administration has been working to lower prices for drugs and energy.

“Though inflation has declined, prices of key goods that matter to middle-class Americans remain too high, so we are taking additional action,” Ms. Yellen said.

While rising prices have haunted consumer sentiment for months, the latest indicators have shown signs of greater optimism. The University of Michigan’s preliminary survey for January showed an unexpected surge in consumer sentiment that pushed the index to its highest level since July 2021, before inflation surged.

Commerce Department figures released on Thursday showed that the U.S. economy continued to grow at a healthy pace at the end of 2023, with gross domestic product, adjusted for inflation, growing at a 3.3 percent annual rate in the fourth quarter.