TOKYO, March 5 (Reuters) - Japan's Nikkei share average erased most of its early losses to end flat on Tuesday as investors bought stocks on dips after the benchmark index slipped from a record high.

The Nikkei inched down 0.03% to 40,097.63, narrowing most of its 0.7% loss earlier in the session.

"Investors bought back stocks on dips. Overall, the market was firm. The Nikkei fell today just because those stocks which lifted the Nikkei declined," said Naoki Fujiwara, senior fund manager at Shinkin Asset Management.

After five consecutive weeks of gains, the Nikkei breached the 40,000 level for the first time on Monday and has risen nearly 20% so far this year.

Chip-testing equipment maker Advantest slipped 2.64%, weighing the most on the Nikkei, while chip-making equipment maker Tokyo Electron reversed course to end 0.41% higher to become the biggest support for the index.

"Investors sold the chip-related shares, which were heavily bought in the rally after Wall Street fell overnight," said Jun Morita, general manager of the research department at Chibagin Asset Management.

The three main indexes in the United States ended lower overnight as investors took a pause ahead of economic data and Federal Reserve Chair Jerome Powell's congressional testimony.

The broader Topix cut its early losses to end 0.5% higher at 2,719.93.

Obayashi Corp surged 18% to a daily limit high after the general contractor raised its dividend forecast. Peers Kajima Corp and Taisei Corp rose 6.49% and 8.81%, respectively.

The construction sector rose 2.96% to become the top performer among the Tokyo Stock Exchange's 33 industry sub-indexes.

Fast Retailing edged up 0.25% after the Uniqlo-brand clothing store operator said its existing store sales in February rose 7.2% from a year earlier.

Of the 225 Nikkei components, 124 stocks rose and 99 fell, while two were flat. (Reporting by Junko Fujita; Editing by Rashmi Aich and Sohini Goswami)