The stock market has roared back to record-high territory — and the number of U.S. millionaires is not far behind, according to a new report.

The number of U.S. households worth $1 million or more, excluding the value of their homes, surged to nearly 9 million in 2012. That is just below its pre-recession peak of 9.2­ million, according to a report by the Spectrem Group, a Chicago area financial consultant firm.

The economic downturn caused the stock market to tumble by more than half between October 2007 and March 2009, when the Dow Jones industrial average hit a low of 6443. The fall decimated the nation’s ranks of millionaires, which slipped to 6.8 million in 2008 after hitting its peak the previous year, Spectrem said.

But the market is back. The Dow closed Thursday at a record high of 14,539, continuing a long surge that has also lifted hundreds of thousands of American families above the millionaire mark. (The Dow, however, dropped to 14,514.11 on Friday.)

Spectrem’s latest count, which the firm arrived at by combining Census Bureau data with information developed by private sources, puts the number of U.S. millionaires at 8.99 million.

The number of millionaires is increasing.

“Just as the stock market crash triggered a steep drop in the net worth of wealthy investors, the rebound in equities has made it possible for many affluent households to largely recover,” Spectrem President George H. Walper Jr. said in a statement.

The firm said the stock market rally lifted the number of households with $500,000 or more in net worth to 14.3 million in 2012, up half a million from a year earlier.

Meanwhile, the number of what Spectrem calls high-net-worth individuals — those whose wealth is between $5 million and $25 million — reached 1.14 million at the end of 2012, up from 1.078 million a year earlier.

The benefits being reaped by those at the top of the wealth ladder from the booming stock market is in sharp contrast to the gains of many Americans. More than 12 million Americans are unemployed, incomes are flat and more than 40 percent of the jobless have been out of work for six months or more.

In a paper released in November, Edward N. Wolff, a New York University economist, pointed out that stock ownership is highly concentrated among the affluent. In 2010, he found, the wealthiest 1 percent of Americans owned 35 percent of households’ stocks, including retirement accounts and mutual funds. The next 9 percent of wealthiest households held 46 percent of stocks.

Others researchers, however, have said that despite that concentration, average Americans benefit from the “wealth effect” that accompanies a rising stock market. When stocks do well, pensions funds are more flush and tax revenues rise, they said.

Mark J. Perry, an economist at the University of Michigan at Flint who is also a scholar at the American Enterprise Institute, said in an e-mail that “rising stock prices are often shared with workers” through profit-sharing and bonuses.

One example, he said, is the auto industry. He said Ford is paying $8,300 in profit-sharing to all hourly workers. That money even goes to new hires at the bottom of the wage scale, for whom the payout is equal to nearly a quarter of their annual pay, he said.

Chrysler workers are getting $2,250, Perry said, and General Motors plans to pay $6,750 to each of its hourly workers.

In total, Perry said more than $360 million in profit-sharing checks will be paid out by Detroit’s Big Three automakers. The ripple effects in the region will be big, he said, with the money sure to go to down payments on homes, remodeling projects and other big-ticket items.

People who own no stock also indirectly benefit, he said, when charitable foundations see gains from their endowments, allowing them to fund more community projects. A bull market also helps college scholarship funds to become more flush and encourages the rich to be more generous.

“As individuals become wealthier from stock market gains, they increase giving to charity, which then helps provide more funding targeting at low-income groups,” Perry said.