Stocks mostly rose in volatile trading on Tuesday, led by materials and financial shares, but investors shied away from big-cap technology shares on concerns about their European exposure.

Once again, the market was treated to late-day volatility, this time with stocks closing at or near session highs after a wobbly session.

Overnight, Federal Reserve Chairman Ben Bernanke said the U.S. economy seemed to have enough momentum to avoid a double-dip recession, giving support to domestic-oriented companies.

Investors are sort of cautiously paring back their international exposure and, even within the S&P 500, trying to position in a domestic theme, said Jack Ablin, chief investment officer of Harris Private Bank in Chicago.

Banks, telecommunications services and consumer staples shares ranked among the top performers. AT&T , a Dow component, rose 2.7 percent to $24.97. Bank of America Corp rose 3.4 percent to $15.33 and Procter & Gamble Co gained 2.5 percent to $62.14.

The Dow Jones industrial average <.DJI> gained 123.49 points, or 1.26 percent, to 9,939.98. The Standard & Poor's 500 Index <.SPX> rose 11.53 points, or 1.10 percent, to 1,062.00. But the Nasdaq Composite Index <.IXIC> dropped 3.33 points, or 0.15 percent, to 2,170.57.

From a technical view, short-term momentum is showing negative signals as the S&P's 14-day moving average has traded below the 200-day moving average for a week. At its lowest during the session, the benchmark managed to stay above its 2010 low, with the 1,040 level seen as key support.

The economy of Brazil, Latin America's largest and strongly supported by basic materials, surged at its fastest pace in at least 14 years in the first quarter, fueled by strong investment and domestic demand, government data showed.

An S&P materials stocks index <.GSPM> rose 2.5 percent and ranked as the best-performing sector in the broad S&P 500.

Freeport-McMoRan Copper and Gold rose 4.8 percent to $61.48 and U.S. Steel gained 2.6 percent to $41.34.

An index of New York-traded stocks of Brazilian companies <.BKBR> rose 2.6 percent.

McDonald's Corp gained 2.5 percent to $68.41 after the world's biggest hamburger chain reported a stronger-than-expected rise in global same-store sales in May.

The technology sector was hit after Bank of America-Merrill Lynch cut price targets on several Internet stocks, citing uncertainty over earnings due to the dollar's gains against the euro since April. Inc fell 2.6 percent to $118.84.

Another drag on tech was Microsoft Corp , which lost 0.7 percent to $25.11 after the Dow component said it planned to make a private offering of senior notes in a move to repay short-term debt.

It may be a play on U.S. versus the rest of the world, where tech is probably the most export-oriented, Ablin said.

As European Union finance ministers discussed how to reduce swollen budget deficits to contain a debt crisis, Spanish public service workers staged a one-day strike that underlined the problems governments face in implementing austerity measures.

Investors don't have the confidence that Europe will be able to address its shortfalls, or that European growth can recover enough to help these economies, said Charles Lieberman, chief investment officer of Advisors Capital Management in Paramus, New Jersey.

About 11.1 billion shares traded on the New York Stock Exchange, the American Stock Exchange and Nasdaq, far exceeding last year's estimated daily average of 9.65 billion.

Advancing stocks outnumbered declining ones on the NYSE by a ratio of about 3 to 2, while on the Nasdaq, about three stocks fell for every two that rose.

(Reporting by Rodrigo Campos; Additional reporting by Ryan Vlastelica; Editing by Jan Paschal)