TOKYO, June 9 (Reuters) - Japan's Nikkei index ended Thursday little changed after a rollercoaster session that at one point took it to a five-month high, before the drag from shippers and chip shares countered gains by energy companies and automakers.

The Nikkei closed at 28,246.53, just 0.04% higher, after rallying as high as 28,389.75 less than an hour to the bell, a level not seen since Jan. 18.

The Nikkei had rallied close to 10% over the four weeks to Wednesday, leaving investors wondering about its next move.

Meanwhile, the broader Topix ended lower by 0.05% at 1,969.05.

"From a technical point of view, the Nikkei's recent rally seems heated, and a correction at any moment wouldn't be unusual, but right now stocks are getting support from the yen's steep decline," said Nomura Securities strategist Maki Sawada.

Car and motorcycle manufacturers have rallied amid the yen's rapid decline to ever deeper two-decade lows, boosting the value of U.S sales. The currency sank as low as 134.56 per dollar on Thursday for the first time since February 2002, tracking the widening spread between long-term U.S. and Japanese yields.

Yamaha led with a 3.19% gain, while Mitsubishi Motors added 2.75% and Subaru advanced 2.13%. Toyota gained 0.4%.

Energy was by far the Nikkei's best performing sector, up 2.27%, amid a climb in crude oil prices. Inpex rallied 3.26%.

Uniqlo store operator Fast Retailing gained 1.94% amid plans to raise prices to offset rising costs.

Startup investor SoftBank Group ended 1.73% higher as shares of one of its top investments — Alibaba — rallied on Wednesday along with other Chinese tech names.

Of the Nikkei's 225 component stocks, 113 rose versus 101 that fell and 11 were flat.

Chip-making equipment manufacturers dragged, following a 2.39% overnight slump for the Philadelphia SE Semiconductor Index. Tokyo Electron slid 2.19% and Advantest lost 2.5%.

Shippers tumbled on the uncertain global economic outlook, with Kawasaki Kisen being the Nikkei's biggest percentage decliner, plunging 11.13%. Mitsui O.S.K. Lines slumped 7.74% and Nippon Yusen fell 6.99%.

Electronics maker Sharp tumbled 5.71% after forecasting a one-third drop in profit. (Reporting by Tokyo markets team; Editing by Uttaresh.V and Shailesh Kuber)