July 7 (Reuters) - U.S. stocks ended higher after a choppy session on Tuesday, as a rebound in U.S. oil prices helped offset concerns about a slowdown in China and the Greek debt crisis.

The S&P energy index reversed course to trade up 0.9 percent as U.S. crude oil rose 0.7 percent after trading as much as 3.7 percent lower earlier in the day.

Oil markets have been keeping a close eye on negotiations between Iran and six major powers over a nuclear deal. The sides gave themselves at least until Friday to reach an agreement on the Iranian nuclear program, but a source from one of the powers said on Tuesday they had to wrap up in the next 48 hours.

“The decline in oil ended,” said Stephen Massocca, Chief Investment Officer at Wedbush Equity Management LLC in San Francisco. “Energy stocks bounced, and when that happened it helped the indices move higher.”

Euro zone leaders held an emergency meeting in Brussels on Tuesday and plan another on Sunday to approve a plan to aid Greece if creditor institutions are satisfied in the meantime with a Greek loan application and reform commitments.

German Chancellor Angela Merkel said she expected a formal loan request from Athens on Wednesday and more detail on how Greece would cooperate to make its economy more competitive on Thursday, in order to seek the approval of the German parliament to start negotiations.

The Dow Jones industrial average rose 93.33 points, or 0.53 percent, to end at 17,776.91. The S&P 500 gained 12.58 points, or 0.61 percent, to 2,081.34 after briefly falling below its 200-day moving average. The Nasdaq Composite added 5.52 points, or 0.11 percent, to 4,997.46.

Nine of the 10 major S&P 500 sectors finished higher. The utilities index jumped 2.48 percent while the materials index was down 0.33 percent.

Some investors believe the storm clouds over Greece and China may give the Federal Reserve reason to hold off raising U.S. interest rates, or at least slow the pace of their rise.

“The U.S. economy should benefit from lower interest rates and lower oil prices that are a result of a slower China and the Greek crisis,” said Paul Zemsky, chief investment officer, Multi-Asset Strategies and Solutions, at Voya Investment Management.

A warning from Chipmaker Advanced Micro Devices about weak demand for personal computers pushed its shares 15.4 percent lower and hurt peers such as Nvidia and Intel .

Advancing issues outnumbered declining ones on the NYSE by 1,837 to 1,248, for a 1.47-to-1 ratio on the upside; on the Nasdaq, 1,636 issues fell and 1,150 advanced for a 1.42-to-1 ratio favoring decliners.

The benchmark S&P 500 index posted 14 new 52-week highs and 48 new lows; the Nasdaq Composite recorded 46 new highs and 166 new lows.

About 8.6 billion shares traded on all U.S. platforms, according to BATS exchange data, well above the average of 6.9 billion in the past five sessions. (Additional reporting by Tany Agrawal; Editing by Chizu Nomiyama and James Dalgleish)