A warning about China's growth sparked selling in energy and industrial shares on Tuesday, but the broad market's losses were contained, a sign of resilience for U.S. stocks.

The steady drumbeat of calls for a correction has not abated since the S&P 500 hit its highest level in nearly four years. Signs of a slowdown in China were the catalyst for selling, though the S&P 500 ended far off the day's lows.

The S&P energy index <.GSPE> fell 1.4 percent and ranked as the worst performer among the S&P 500 sectors. Global mining giant BHP Billiton said it saw signs of flattening iron-ore demand from China, the world's top metals consumer, hitting the commodities markets and energy stocks.

The news out of China caused everyone to look up and take a breath, but the sentiment hasn't changed. It's still bullish, said Mike Shea, managing partner and trader at Direct Access Partners in New York.

Before Tuesday, the S&P 500 index was at its highest point since May 2008 and about 10 percent below the record closing high of 1,565.15 set in October 2007.

Easing concerns about the euro zone's debt crisis and improving U.S. economic data have lifted the S&P 500 by 11.8 percent for the year and over 27 percent from an October low.

Permits for U.S. homebuilding neared a 3-1/2 year high in February, even as groundbreaking activity slipped, suggesting a nascent recovery in the housing sector was still on track.

Consumer stocks advanced, led by a gain of almost 4 percent in Amazon a day after the online retailer agreed to buy Kiva Systems for $775 million in cash.

Amazon is at the forefront of warehouse management and truly becoming what they have invested a lot of money into, said King Lip, chief investment officer at Baker Avenue Asset Management in San Francisco. This was a smart purchase.

The advance in Amazon and luxury retailer Tiffany, alongside continued strength in bank shares, helped erase most of the day's losses in late trading. The S&P retail index <.RLX> rose 1 percent and the KBW bank index <.BKX> added 0.4 percent.

The Dow Jones industrial average <.DJI> fell 68.94 points, or 0.52 percent, to 13,170.19 at the close. The S&P 500 Index <.INX> lost 4.23 points, or 0.30 percent, to 1,405.52. The Nasdaq Composite <.IXIC> dipped 4.17 points, or 0.14 percent, to 3,074.15.

About 6.2 billion shares changed hands on the New York Stock Exchange, the Nasdaq and Amex, compared with the daily average so far this year of 6.9 billion shares.

Amazon jumped 3.7 percent to $192.33 in more than twice the previous 10 days' average volume.

Shares of Tiffany & Co surged 6.7 percent to $73.27 after the jewelry chain forecast higher sales this year, helped by expansion in Asia and the Americas.

Lions Gate Entertainment shares hit an all-time high of $15.30 ahead of the release of its highly anticipated movie, The Hunger Games. Its stock closed up 7.2 percent at $15.28.

Adobe Systems Inc lost 3.9 percent to $33.16 a day after the maker of Photoshop and Acrobat software reported that quarterly revenue growth slowed, missing forecasts.

Declining issues beat advancers on the New York Stock Exchange by more than 2 to 1, while on the Nasdaq, seven issues fell for every three that rose.

(Reporting by Rodrigo Campos; Additional reporting by Angela Moon; Editing by Jan Paschal)