The nation’s benchmark stock index closed at its highest level in nearly four years Friday, marking a milestone in the long, slow climb from recession that could help recalibrate a presidential campaign dominated by the economy.

The S&P 500-stock index closed at 1365.74, its highest level since June 2008, when the nation was on the brink of the financial collapse that triggered the most severe recession since the Great Depression. The Dow Jones industrial average also topped 13,000 early Friday before closing at 12,982.95. The Dow hasn’t closed above the psychologically signifcant 13,000 level since May 2008, and hit a low of 6547 on March 9, 2009.

The turnaround in the stock market offered an encouraging counterpoint to the spiraling gas prices that have hurt Americans’ wallets. A survey of consumer sentiment released Friday by the University of Michigan/Reuters showed that households have become increasingly pessimistic about their financial situation and more optimistic about the economy over the long haul.

“Stock prices reflect peoples’ belief about the future,” said James J. Angel, a finance professor at Georgetown University. “If stock prices go up, it means people have a more optimistic view about the future.”

The surging stock indexes — the Dow is up 20 percent since the fall — are not the only indicator suggesting that the country’s nascent economic recovery is sustainable. The unemployment rate, which stood at 9 percent as recently as September, is down to 8.3 percent. Manufacturing output is up.

Despite the recent good news, the White House has been careful to temper its increasing confidence in the recovery with an acknowledgement of the toll that the continued spike in oil and gasoline prices is taking on household budgets. Oil prices are over $109 a barrel, the highest level in more than nine months. Meanwhile, the average price of a gallon of regular gasoline in the United States is $3.59, a 30-cent increase since the beginning of the year.

“High gas prices are like a tax straight out of your paycheck,” President Obama said this week. He later added, “We’re going to look at every single aspect of gas prices because we know the burden that it’s putting on consumers. “

Meanwhile, Obama’s Republican rivals have jumped on the price hikes as an example of the president’s mishandling of the economy and flawed policies on domestic drilling and climate change. Former senator Rick Santorum implied this week that higher gas prices were part of the administration’s attempt to reduce American’s reliance on cars and to lower emissions. Former House speaker Newt Gingrich has promised that he would lower the price at the pump to $2.50 a gallon.

Like gasoline prices, the stock market is notoriously volatile and wields increasing influence over Americans’ perception of their financial well-being. The profusion of 401(k) retirement plans and mutual funds means that what happens on Wall Street is felt more quickly by the masses.

When the nation teetered on the brink of default last summer, the markets tanked and Obama’s approval ratings plummeted. Now, he is enjoying the opposite phenomenon: surging stocks and a bump in voter approval.

“The markets’ ups and downs have a greater political effect than it used to,” Democratic pollster Peter D. Hart said.

Analysts added that the performance of the stock market plays a key role in shaping voters’ assessment of the broader economy, beyond their personal financial situation.

“The thing about the stock market is that it’s there every day. People are voting every day with their dollars,” said John Prestbo, editor and director of Dow Jones Indexes. “If the economy keeps on improving, President Obama’s chances get better and better. Well, the stock market is part of the economy, and it’s the only part that gets reported every second of every day.”

Robert Erikson, a political science professor at Columbia University, pointed to the 1996 presidential race between Bill Clinton and Bob Dole. The Republicans had recently won control of Congress and thought they could gain back the White House as well. But in early 1996, the stock markets began surging along with other leading economic indicators and Clinton found himself within a comfortable margin of victory.

“People discount the past to some extent,” Erikson said. “It’s the rate of change that matters. A period of obvious growth could benefit the president . . . even if it starts from a low level.”