Hong Kong and China shares reversed early losses to end higher on Tuesday, led by financial stocks, after euro zone finance ministers sealed a second bailout for Greece that will resolve its immediate financing needs.

Chinese oil majors were a drag on both markets on fears that escalating oil prices could crimp earnings, sparking more profit-taking after their recent outperformance.

The Shanghai Composite Index closed up 0.8 percent at 2,381.4, its highest close since Dec. 1 but just shy of its 125-day moving average, currently at 2,388.2. A decisive break of this resistance level could point to further gains.

The China Enterprises Index of the top mainland listings in Hong Kong rose 0.2 percent.

The Hang Seng Index gained 0.3 percent, and faces resistance at 21,725.7, the top end of a gap that opened up between Aug. 4 and 5, a level it briefly tested on Monday.

People are selling into strength, trying to lock in some profits from the outperformers so far. That we bounced off the day's lows suggests we have support at that level and the rally could have some more room ahead, said Alex Wong, director of asset management at Ample Finance.

Much could depend on the HSBC China flash purchasing managers' index (PMI) for February, the earliest indicator of factory activity in the mainland, scheduled for Wednesday, which will give investors fresh clues on the extent of the slowdown in the world's second-largest economy.

HSBC Holdings Plc, Europe's largest bank and the Hang Seng Index's biggest weighted component, gained 1.3 percent to HK$71.65, the highest since early August last year. Its next major target is at HK$73.30, the bottom of a gap that opened up between Aug. 4 and 5.

Chinese banks were strong in both markets. The mainland's largest lender, Industrial and Commercial Bank of China gained 0.9 percent in Hong Kong and 1.4 percent in Shanghai.

CHINESE OIL MAJORS WEAK FOR SECOND STRAIGHT DAY

Markets were weighed down for much of the day by weakness in Chinese oil majors.

CNOOC Ltd led percentage losses in the sector in Hong Kong, down 2.9 percent with Brent crude futures steady near $120 per barrel on a cut in Iranian oil supply to China and Europe.

If oil prices stay at this level, profits could suffer if the Chinese government does not relent on its domestic pricing controls, said Edward Huang, an equity strategist with Haitong International Securities.

CNOOC has slipped 4.2 percent in the last two days since opening on Monday at its highest intraday level since July last year. Still up almost 28 percent in 2012 so far, CNOOC is among the leading lights of a rally that has lifted the China Enterprises Index 17.6 percent and the Hang Seng Index 16.5 percent.

PetroChina Co Ltd slipped 0.5 percent in Hong Kong and 0.3 percent in Shanghai. China Petroleum & Chemical Corp (Sinopec) lost 1 percent in Hong Kong and 0.7 percent in Shanghai.

Sinopec has lost 6.4 percent in Hong Kong in two days after a downgrade over the weekend by Citibank analysts, who cut its target price from HK$10.90 to HK$9.90, saying earnings would struggle to keep up with its share price.

They pointed to deteriorating chemical margins and negative refining margins that will make Sinopec's current operating environment more challenging in the first half this year compared with the same time period last year.

Sands China Ltd slid 3.1 percent to HK$29.80 after CLSA downgraded the stock from buy to outperform, while maintaining its target price at HK$35.50, urging investors to take profit. Before Tuesday, it had surged more than 40 percent this year, following a 28.5 percent gain last year.