The Nikkei average rose 0.45 percent on Tuesday to close above the psychologically important 18,000 for the first time in three months as Tokyo got support from energy stocks such as INPEX Holdings Inc after oil prices topped $70 a barrel.
Exporters also rose after stocks gained in the United States, one of the biggest markets for Japanese goods. The benchmark average trimmed some of its early gains in the afternoon as China's main stock index dropped nearly 6 percent, but recovered somewhat as Shanghai stocks regained ground.
Market participants said the recent slide in Shanghai was unlikely to have a lasting impact on Tokyo stocks. "Investors have begun to think the Chinese market is doing its own thing, and its impact is getting weaker as you can see from how New York stocks did the previous session," said Katsuhiko Kodama, Toyo Securities' senior strategist.
US stocks rose on Monday, with the Dow and the S&P 500 eking out closing records, as higher energy shares and a fresh round of take-overs offset concerns about the sell-off in China.
The Nikkei added 80.39 points to 18,053.81, finishing above 18,000 for the first time since February 27. The broader TOPIX index gained 0.21 percent to 1,776.56. Trade volume grew, with 2.3 billion shares changing hands, compared with last week's daily average of 2 billion shares.
Advancing shares outnumbered decliners by 907 to 693. Among exporter gainers, Advantest Corp added 1.9 percent to 5,400 yen, and Kyocera Corp gained 0.9 percent to 12,030 yen. Meanwhile, Fast Retailing Co Ltd, the operator of casual-wear chain Uniqlo, became the biggest percentage loser among Nikkei 225 stocks, falling 4.3 percent to 8,900 yen on weak May sales.
Shares in Nippon Mining Holdings, which owns oil unit Japan Energy, climbed 2.4 percent to 1,141 yen and Nippon Oil Corp, Japan's largest oil distributor, gained 3.8 percent to 1,112 yen after London Brent crude jumped $1.33 to $70.40 on Monday.
Shares in INPEX were up 4.6 percent to 1.15 million yen. Elsewhere, Tokyo Rope Manufacturing Co Ltd jumped 7.1 percent to 240 yen after it said it planned to buy back up to 2 million shares or 1.2 percent of its outstanding stock between June 6 and September 30. Rohm Co Ltd rose 2.4 percent to 11,090 yen after Mizuho Securities raised its investment rating on the Japanese microchip maker to "1" from "3".
Web technology and consultancy firm Internet Research Institute Inc (IRI) surged 13.1 percent to 8,650 yen after Orix Corp, Japan's largest leasing firm, said on Monday it would buy IRI in a deal worth about 10.6 billion yen.
Orix said it would swap 0.667 of its shares for each of Tokyo-based IRI's shares, and that the deal would be completed by mid-November. Shares of Orix were down 0.6 percent to 32,450 yen.
Hiroyuki Fukunaga, chief strategist at Rakuten Securities, said the market now sees a drop in China stocks as a response to the government's effort to kill the bubble and as temporary. He said the worst scenario would be a stock sell-off as a result of a slowing economy, which did not seem to be the case this time. "It would be also another story if the Chinese government decided to raise interest rates," he said.