NEW YORK — U.S. stocks closed higher on Monday as investors staged a late-day rebound, extending a recent trend of buying on dips and pushing major indexes near all-time highs despite concerns about growth and China’s housing market.

The Dow closed within 40 points of its all-time closing high, recovering from early losses on plans to tighten curbs on China’s housing market, as well as a slowdown in the growth of that country’s services sector.

Any slowdown in the world’s second-largest economy could affect U.S. growth, especially commodities and materials, which have a lot of exposure to China. Industrial and material shares were among the weakest of the day, with Caterpillar Inc. off 1.8 percent at $89.75 and Alcoa Inc. down 1.1 percent at $8.35.

Google shares touched a lifetime intraday high of $822.84. The dominant Internet search company’s stock was up 1.9 percent at $821.50 at the close.

The S&P 500 has jumped about 7 percent so far in 2013 as investors continue to view equities as more attractively valued than other asset classes, allowing stocks to resist calls for a pullback even with few obvious catalysts to drive shares definitively higher.

“There are a lot of worries out there, but also a lot of positive momentum. Stocks remain the only game in town if you want yield,” said Randy Bateman, chief investment officer of Huntington Asset Management in Columbus, Ohio, who helps oversee $14.5 billion.

“So many people think we’re overextended that a pullback could happen at any time, but there are also so many people re-entering the market on dips that I wouldn’t be surprised to see a new high on the Dow sometime this month.”

Concerns about “automatic” budget cuts in the United States and the euro-zone debt crisis also have served as reasons for investors to take a breather in the face of technical resistance. Any sign that the $85 billion in cuts are beginning to take a toll on the economy could jostle markets.

The Dow Jones industrial average rose 38.16 points, or 0.27 percent, to 14,127.82 at the close. The Standard & Poor’s 500 Index gained 7.00 points, or 0.46 percent, to 1,525.20. The Nasdaq Composite Index added 12.29 points, or 0.39 percent, to end at 3,182.03.

Retail stocks ranked among the strongest of the day after Deutsche Bank raised price targets on Target Corp. and Macy’s Inc. Target climbed 3.6 percent to $66.44 while Macy’s rose 2.1 percent to $41.54. The S&P retail index jumped 1.5 percent.

Bucking the trend was J.C. Penney Co., which is struggling to compete against its rivals. J.C. Penney’s stock fell 5.4 percent to $16.74.

Investors will also keep an eye on Europe, with Italy possibly inching toward another election within months after center-left leader Pier Luigi Bersani issued an ultimatum to anti-establishment 5-Star Movement boss Beppe Grillo to support a new government or return to the polls.

Janet Yellen, the Federal Reserve’s influential vice chairwoman, provided some support for the market when she said the central bank’s aggressive monetary stimulus is warranted, given how far below its full potential the economy is operating.

Hess Corp. shares rose 3.5 percent to $68.84 after the company said it will exit its retail, energy marketing, and energy trading businesses. Hess also boosted its dividend by 150 percent and announced a stock-buyback program.

Ferro Corp. shares surged 30.8 percent to $6.80 after A. Schulman Inc. offered to buy the company for $563 million, although Ferro rejected the bid.

About 6.01 billion shares changed hands on the New York Stock Exchange, the Nasdaq and NYSE MKT, below the daily average so far this year of about 6.48 billion shares.

Roughly 53 percent of stocks traded on the New York Stock Exchange closed higher, while 51 percent of Nasdaq-listed shares ended in positive territory.