Inflation climbs to 7.9 percent, a new four-decade high.

Prices increased 7.9 percent in the year through February, the fastest pace of inflation in 40 years, as gas prices increased and a wide array of goods and services grew more expensive.

The rising cost of gas, food and rent all contributed to the big increase, the Bureau of Labor Statistics said, and economists expect inflation to pick up even more in March as war in Ukraine pushes prices at the pump to record-breaking highs.

Rapidly climbing prices have hit consumers in the pocketbook, causing confidence to fall and stretching household budgets. Rising wages and savings amassed during the pandemic have helped families continue spending despite rising prices so far, but the burden is falling intensely on lower-income households, which devote a big chunk of their budgets to daily necessities that are now swiftly becoming more expensive.

The price burst presents a challenge for the White House, especially given November’s midterm elections are fast approaching. Sanctions and other economic responses to Russia’s war in Ukraine promise to keep inflation elevated, at least for a while, as gas prices rise.

The quickest inflation in most Americans’ lifetimes is also a problem for the Federal Reserve, which is in charge of achieving price stability. The central bank has signaled it will raise interest rates by a quarter percentage point at its meeting next week, probably the first in a series of moves meant to increase the cost of borrowing and spending money and slow down the economy. By reducing consumption and slowing the labor market, the Fed is able to take some pressure off inflation over time.

“Mortgage rates will go up, the rates for car loans — all of those rates that affect consumers’ buying decisions,” Jerome H. Powell, the Fed chair, told lawmakers last week. “Housing prices won’t go up as much, and equity prices won’t go up as much, so people will spend less.”

But even as the Fed prepares to rein in demand, high gas costs could become a serious issue for central bank policymakers if they help convince consumers that the burst in prices will last. If people begin to expect inflation, they may change their behavior in ways that make it more permanent: accepting price increases more readily, and asking for bigger raises to keep up.

While the February report only caught a few days of post-invasion gas prices — most of the recent spike will be felt in the March inflation report — gas prices accounted for about a third of the price index increase, the government said. Omair Sharif, founder of Inflation Insights, said he expects inflation to pick up to 8.3 percent in March as pump prices surge. The average price for a gallon of gas hit $4.32 on Thursday, according to AAA.

President Biden and his advisers have pointed out that part of the recent increase in prices owes to higher fuel costs, attributing that surge to mounting tensions and now war in Ukraine. The White House has in recent days tried to focus some of the blame for high inflation to Vladimir V. Putin, the Russian president.

Energy prices are “a key reason” for the burst in prices, Jen Psaki, the White House press secretary, said on Wednesday, noting that prices were up sharply since “the beginning of the year as Putin built up his military near Ukraine and took increasingly aggressive measures that were felt in the markets.”

The Ukraine invasion and its fallout in global energy markets is just the latest instance, as far as prices go, in which what can go wrong does seem to be going wrong.

Fast inflation began to kick in early last year, and economists initially predicted that it would fade by the end of 2021 as the economy reopened from the pandemic and conditions returned to normal.

Instead, turmoil in supply chains collided with strong consumer demand for goods, and price gains accelerated. Now, how quickly and how much prices will moderate in 2022 are increasingly uncertain as conflict abroad threatens to keep shipping routes tangled and key parts scarce. Ukraine is an important producer of neon, which could keep computer chips in short supply, perpetuating the shortages that have plagued automakers. Higher energy costs could ricochet through other industries.

Even without further supply chain troubles, there are signs that inflation is widening beyond a few pandemic-affected sectors, a sign that they could last. Rent of primary residences, for instance, climbed by 0.6 percent from the prior month — the fastest monthly pace of growth since 1999.

Housing costs make up a big chunk of the overall index and move very slowly and often in response to economic conditions, so Fed and White House officials are likely to take note of that change as something that could keep inflation elevated.

There are still reasons to think price gains will slow somewhat. Starting in the March data, they will be lapping high readings from last year, which should mechanically start to bring down the year-over-year measure if gas prices stop rising so sharply. But it is unclear when they will recede to the Fed’s 2 percent inflation goal. The central bank defines that target using a separate inflation index, but one that is also up considerably.

For people like Timothy Gutbrod, 61 and from Albany, N.Y., the rapid inflation has caused lifestyle changes. Mr. Gutbrod, who formerly worked as a stage actor, has been a driving instructor since March 2020, and the job pays him a little more than $30,000 per year. As higher gas prices have made his commute and everyday purchases more expensive, he has been eating out less.

For someone who was a longtime Manhattanite, that’s a real loss, Mr. Gutbrod said. He used to enjoy three restaurant brunches or dinners each week. Now it’s more like one every two weeks.

“I used to go on relaxing drives,” he said, but now joy rides are unaffordable. “I’m on a shoestring budget, and I work pretty hard. For anyone who doesn’t make a lot of money, you have to be intelligent and start cutting corners.”

As it disturbs everyday lives, inflation is likely to dog Democrats and the administration as they fight to retain control of Congress in November. Despite plentiful jobs and quickly rising wages, consumer confidence has fallen to its lowest level since the summer of 2011, when the economy was clambering back from the global financial crisis and Congress was bickering over lifting the nation’s debt ceiling.

That probably at least partly reflects the reality that pay is not quite keeping up with inflation for the typical worker, and that consumers are paying more at the pump, which tends to be a very salient cost for Americans. Consumer expectations for near-term inflation have moved up markedly.

In February, the costs of food rose, which is also difficult for consumers on tight budgets. Over the past year, grocery prices have increased by 8.6 percent, the largest yearly increase since the period ending in April 1981. The climb in the cost of products including fresh fruit and dairy products was especially notably last month.

The White House has emphasized that it is trying to offset rising costs to the degree that it can.

“We’ve taken steps to address bottlenecks in the supply chain, to reduce those bottlenecks,” Ms. Psaki said this week.

But those changes have mostly helped around the edges, and as prices have shown little sign of moderating on their own, Fed officials have coalesced around the view that they will need to use their policies to cool off demand and keep today’s rapid inflation from becoming entrenched.

Policymakers are likely to closely watch consumer sentiment and inflation expectations to the current high readings and to the jump in energy costs, as they monitor the economy for signs that rapid inflation is already locked in to consumer and company mind-sets.

“Survey measures, particularly for consumers, are sensitive to supply-driven spikes in oil even more than those driven by demand,” Matthew Luzzetti, chief U.S. economist at Deutsche Bank, and his colleagues wrote in a recent research note. “The tentative peaking of inflation expectations could be at risk, with this oil price shock possibly spilling over into higher inflation expectations in the coming months.”