TOKYO, Feb 27 (Reuters) - Japan's Nikkei share average closed nearly flat on Tuesday, giving up most of its early gains as investors sold shares of chip heavyweight Advantest to lock in profits.

The Nikkei inched up 0.01% to close at 39,239.52. The index rose as much as 0.5% to a record 39,426.29 earlier in the session.

A rally in chip-related stocks was a key element which drove the Nikkei past an all-time high marked on the last trading day of 1989.

"The Nikkei did not seem to have a momentum it had at the end of last week," said Seiichi Suzuki, chief equity market analyst at Tokai Tokyo Research Institute.

Chip-testing equipment maker Advantest reversed early gains to fall 2.12%, weighing the most on the Nikkei. Uniqlo-brand clothing store operator Fast Retailing fell 0.3%.

Meanwhile, chip-making equipment maker Tokyo Electron rose 0.72% and technology start-up investor SoftBank Group gained 2.44%.

The bank sector rose 1.69%, lifting the broader Topix 0.18% to end at 2,678.46.

Sumitomo Mitsui Financial Group and Mitsubishi UFJ Financial Group gave the biggest boost to the Topix, rising 2.54% and 1.42%, respectively.

"Investors have shifted their target in the current session. Domestic investors seemed to have scooped up value stocks as they saw those shares were still reasonable," Shigetoshi Kamada, general manager at the research department at Tachibana Securities, said.

The Topix index of value shares rose 0.24%, outperforming a 0.12% gain in growth stocks, which comprises companies with potential for high earnings such as chip-related stocks.

Steel makers jumped 3.16% to become the top performer among the Tokyo Stock Exchange's 33 industry sub-indexes.

Kobe Steel and Nippon Steel rose 4.36% and 4.16%%, respectively.

Trading firms were largely weaker after billionaire investor Warren Buffett's Berkshire Hathaway raised its stake in Japan's top five trading firms to around 9%.

Mitsui & Co inched up 0.09%, while Mitsubishi Corp fell 0.94%. Itochu Corp fell 0.94%. (Reporting by Junko Fujita; Editing by Mrigank Dhaniwala and Varun H K)