TOKYO - Japan's Nikkei share average gave up early gains on Tuesday to close lower, as semiconductor-related shares extended declines in the afternoon session.

The Nikkei closed down 0.4% at 39,376.09, while the broader Topix finished up 0.07% at 2,741.52.

Chip-related shares followed their U.S. peers lower and were the biggest drag on the benchmark Nikkei. The Philadelphia SE Semiconductor index declined 2.5% on Monday.

Investors were weighing a Reuters report published over the weekend that the United States had ordered Taiwan Semiconductor Manufacturing Co to halt shipments of advanced chips to Chinese customers.

Nikkei heavyweights Advantest and Tokyo Electron slid 3.2% and 2.8%, respectively, while Lasertec fell 4.4%.

AI-focused startup investor SoftBank Group shed 1.1%. After market hours, the company posted quarterly earnings above expectations.

Tokyo Electron also reported its financial results after the market close.

"The Nikkei is not exactly overheated in terms of technical indicators, but given its solid momentum over the past few days, I think we might be seeing some moves to secure profits," said Nomura Securities strategist Maki Sawada.

The Nikkei briefly rose as high as 39,866.72 before closing lower for the first time in three sessions. The index had closed at its highest in three weeks last Wednesday.

Meanwhile, a weaker yen lent some support to Japan's export-related shares. Automakers rallied, with Toyota Motor and Suzuki Motor both up about 2.4%.

The transport equipment sector, which includes Toyota Motor and other automakers, was the best performing sector with a 1.9% rise.

Among other stocks, Recruit Holdings gained 3.8% after the staffing agency revised upward its profit forecast on Monday.

Nissan Motor jumped as much as 20.6% after a filing showed an entity related to activist investor Effissimo Capital Management had taken a stake in the struggling automaker.

(Reporting by Brigid Riley; Editing by Sonia Cheema and Subhranshu Sahu)