Wall Street rose modestly on Tuesday, led by gains in the consumer discretionary sector after McDonald's posted global sales that were above Wall Street's estimates.

Stocks wavered between small gains and losses as energy shares weakened after China's central bank raised interest rates to tackle inflation. But the market brushed off the news by midday and resumed the rally that has pushed the Dow and the S&P to their highest in 2 1/2 years.

Dow component McDonald's Corp posted stronger-than-expected global sales at established restaurants as demand in Europe rebounded. The stock rose 3 percent to $65.67.

It would take something unforeseen to derail this rally, and China's rate hike was something that investors were expecting. They are expecting that not only from China but from all over the world, said Timothy Harder, chief in investment officer at Peak Investment Services is Denver, Colorado.

The unwinding of pessimism is now slowly turning into optimism.

The Dow Jones industrial average <.DJI> was up 35.57 points, or 0.29 percent, at 12,197.20. The Standard & Poor's 500 Index <.SPX> was up 2.60 points, or 0.20 percent, at 1,321.65. The Nasdaq Composite Index <.IXIC> was up 1.50 points, or 0.05 percent, at 2,785.49.

The S&P consumer discretionary index <.GSPD> was up 0.6 percent and was the top performing among S&P 500 sectors.

Merger activity continued for a second day with Kindred Healthcare Inc's planned acquisition of RehabCare Group Inc to create a post-acute healthcare services company.

Kindred Healthcare jumped 23.6 percent to $24.08 and RehabCare soared 43.9 percent to $36.65.

But some earnings disappointed investors.

Teva Pharmaceutical Industries' shares fell 6.4 percent to $51.50 after the world's biggest maker of generic drugs reported results that fell short of forecasts.

Avon Products Inc posted a steeper-than-expected drop in quarterly profit, pushing shares of the world's largest direct seller of cosmetics down 5.2 percent to $27.83.

Beazer Homes USA also reported a wider-than-expected first-quarter loss, sending the stock down 1.5 percent to $5.37.

In the latest move to battle inflation, China's central bank raised interest rates by 25 basis points, its second increase in six weeks.

The S&P energy index <.GSPE> fell 0.6 percent to be the worst-performing sector on the index.

(Reporting by Angela Moon, Editing by Kenneth Barry)