By Junko Fujita
TOKYO, July 9 (Reuters) - Japan's Nikkei share average surrendered early gains to trade flat on Wednesday, as investors sold chip-related heavyweights to book profits from a recent rally.
The Nikkei .N225 was down 0.03% at 39,677.42 by the midday break, after rising 0.7% earlier in the day to 39,971.06. The index swung between marginal gains and losses during the session.
The broader Topix .TOPX was up 0.3% at 2,824.93.
"The Nikkei opened higher, supported by the yen's weakness against the dollar. But as soon as the Nikkei rose closer to the 40,000 level, investors sold stocks to book profits," said Shuutarou Yasuda, a market analyst at Tokai Tokyo Intelligence Laboratory.
"Overall, the market is firm, with the Topix rising. Investors are rotating their targets day to day."
Chip-related heavyweights Advantest 6857.T and Tokyo Electron 8035.T gave up early gains and were trading down 1.87% and 0.92%, respectively.
Uniqlo-brand owner Fast Retailing 9983.T lost 1.18%.
Automakers rose on the back of a weaker yen, with Toyota Motor 7203.T and Honda Motor 7267.T up 1.36% and 2.83%, respectively.
The yen JPY= weakened 0.2% to 146.91 against the dollar. The greenback extended gains as U.S. President Donald Trump pledged more trade-related proclamations after announcing 25% tariffs on Japan and other trade partners. FRX/
A weaker Japanese currency tends to boost shares of exporters, as it increases the value of overseas profits in yen terms when firms repatriate them to Japan.
Energy-related shares rose after oil prices hit a two-week high overnight. An index for oil refiners .IPETE.T jumped 3% to become the top performer among the Tokyo Stock Exchange's 33 industry sub-indexes.
Yoshinoya Holdings 9861.T jumped 6.56% after the fast-food chain known for "gyudon" beef bowls reported a 9% gain in quarterly net profit, supported by strong sales of its new ramen business.
Of the more than 1,600 stocks trading on the TSE's prime market, 82% rose, 15% fell, and 2% traded flat.