The federal deficit will hit $3 trillion in 2021 for the second consecutive year, primarily because of the national spending blitz in response to the coronavirus pandemic, the Congressional Budget Office said Thursday.

The deficit represents a slight decrease from last year but is triple that of 2019, and amounts to one of the biggest imbalances between federal spending and revenue in American history, the nonpartisan budget office said. But the CBO also projected faster-than-expected economic growth, with unemployment falling more sharply than previously predicted — a shift cheered by administration officials.

In 2021, the federal government is projected to spend $6.8 trillion — higher than even last year’s total — while collecting about $3.8 trillion in revenue. Although spending is elevated from last year, the United States will take in more revenue as the pandemic fades and consumers resume normal activities — which is why the overall deficit will shrink modestly.

President Biden’s $1.9 trillion stimulus, passed in March, accounts for much of this year’s spending imbalance. But that measure is temporary and will soon expire. The CBO projects the deficit will fall to $1.2 trillion in 2022 before dropping to $800 billion in 2023 and 2024 as pandemic relief measures fade. However, the budget office projects that the deficit will again begin to widen in 2025 and grow steadily for the rest of the decade, approaching close to $2 trillion by 2031.

“It’s more than any other year besides last year, which is in line with what we expect given the American Rescue Plan,” said Marc Goldwein, senior vice president at the nonpartisan Committee for a Responsible Federal Budget.

The CBO projects brisk economic growth, with the nation’s gross domestic product surging to 7.4 percent in 2021 before leveling off at a still-robust 3.1 percent in 2022. It also projects the unemployment rate falling to 3.8 percent in 2022.

The forecast calls for a sharp rise in inflation, close to 3 percent in 2021, then falling to about 2 percent by 2022 and remaining around that level through 2025 at its pre-pandemic rate. The drop is in line with expectations from the Federal Reserve and the Biden administration.

“CBO is not in the camp that we need to panic, but it’s still worth keeping an eye on things because demand is growing rapidly and it may grow faster than supply,” said Kyle Pomerleau, a policy expert at the American Enterprise Institute, a right-leaning think tank.

Biden’s relief plan approved emergency assistance in $1,400 stimulus payments, unemployment benefits, aid to local governments and other measures. Democrats and many economists have said that the spending was important to ensure avoiding a repeat of the slow economic growth that characterized the recovery from the Great Recession. Interest rates have also remained low, which makes federal borrowing cheap.

“If there’s one thing we should have learned from the last 10 years, it’s that fears of government debt have been greatly exaggerated,” said J.W. Mason, professor of economics at the City University of New York. “In the U.S. and other rich countries, we have seen historically high debt levels with none of the negative consequences that they were expected to bring.”

Brian Riedl, a budget expert at the libertarian-leaning Manhattan Institute, said lawmakers must act to lower the national debt, particularly because a spike in interest rates could cause federal spending to soar.

Riedl pointed out that the CBO’s estimates assume the expiration of many spending policies that lawmakers are expected to extend, such as the expanded child tax credit approved in March.

“This report reemphasizes that the debt is growing at an unsustainable pace,” Riedl said.

Still, administration officials said they were encouraged by the CBO numbers, which pointed to a faster economic recovery than the budget agency predicted before the stimulus passed and much of the national vaccine campaign. The CBO projects growth to be almost twice as fast as its forecast in February, while its expectations for a labor market recovery are also significantly more optimistic than this winter. In February, the CBO projected an unemployment rate of close to 5 percent for the end of 2022 — but now thinks it will be 3.6 percent, a sign that millions of people will find jobs.

“This is a report that shows what happens when we have a successful deployment of policy in the midst of a crisis,” said David Kamin, deputy director of the White House National Economic Council, in an interview.

Still, the extent of the debt burden is expected to make lawmakers reticent about additional spending. In addition to the annual deficit, the total amount of debt held by the federal government is set to increase throughout the decade. The total national debt will increase to $35 trillion by 2031, the CBO said, compared with $23 trillion this year. The total debt held by the federal government will be approximately the same amount as the size of the entire economy across the decade, increasing slightly over time. The cumulative deficit in the next 10 years is expected to hit about $12 trillion. That is slightly smaller than previously projected by the CBO.

The deficit widened primarily because the pandemic pushed spending to levels never before seen in the United States. The CBO said that total spending by the federal government amounted to about 31 percent of GDP in 2021, but will fall to more normal levels of about 22 percent for the rest of the decade as the stimulus fades. But policy experts have pointed out that these levels of spending are not unusual for other developed nations, particularly in Europe — though those countries also tax at levels high enough to pay for the expenditures without exploding their debt totals.

“The U.S. is still going to spend less than 50 percent of GDP during the pandemic years, and that’s right in line with what most European countries spend every year — even without the pandemic,” said Matt Bruenig, a policy expert at the People’s Policy Project, a left-leaning think tank. “We’re still spending less than a half-dozen European countries spend in a totally normal year.”