South Korean shares notched a record closing high after a volatile session of trading on Tuesday, with technology firms leading the gains on hopes of AI cooperation with Nvidia.

The benchmark KOSPI ended up 13.11 points, or 0.15%, at 8,801.49, its highest closing level on record.

The KOSPI rose as much as 1.7% before falling up to 3.3%. It turned higher again near the session close.

South Korea's consumer inflation quickened in May to a more than two-year high, exceeding market expectations on high oil prices triggered by the Middle East conflict, supporting the case for monetary tightening as early as next month.

Nvidia CEO Jensen Huang hosted top South Korean tech executives on Monday, as he looks to deepen ties with key partners ahead of what he called an "incredibly busy" stretch for the AI boom.

Chipmaker Samsung Electronics rose 3.3% to a record close, while e-commerce firm Naver jumped 3.3%. Home appliance maker LG Electronics gained 3.2%.

Chipmaker SK Hynix lost 0.1%, while Hyundai Motor fell 2.8%.

"Today's volatility is a result of a tug-of-war between continued buying of retail investors and selling of foreign investors in an overheated market," said Seo Sang-young, an analyst at Mirae Asset Securities.

Of the total 924 traded issues, 271 shares advanced, while 636 declined.

Foreigners were net sellers of shares worth 6.6 trillion won ($4.35 billion), extending their selloff to an 18th straight session.

The won was quoted at 1,518.5 per dollar on the onshore settlement platform, 0.37% lower than its previous close at 1,512.9.

The most liquid three-year Korean treasury bond yield fell by 1.3 basis points to 3.774%, while the benchmark 10-year yield fell by 4.0 basis points to 4.127%. ($1 = 1,518.0500 won)