TOKYO, July 8 (Reuters) - Japan's Nikkei index shed most of its early gains to end flat on Friday after Japan's former prime minister Shinzo Abe was shot while campaigning for a parliamentary election.

The Nikkei index closed up 0.1% at 26,517.19 after climbing as much as 1.4% earlier in the session.

The broader Topix index also cut most of its gains to close 0.27% higher at 1,887.43. The Nikkei has gained 2.24% for the week and the Topix 2.3%.

"There must have been mixed reasons for the Nikkei cutting gains today but the accident (of Abe) was one of them, as I believe he still has influence on Japan's economic and monetary policy," said Jun Morita, general manager of the research department at Chibagin Asset Management.

Abe, best known for his signature "Abenomics" policy that featured bold monetary easing and fiscal spending, appeared to have been shot from behind by a man with a homemade gun.

Prime Minister Fumiko Kishida said Abe, 67, was in a grave condition, expressing his wishes for the country's longest-serving prime minister to survive the ordeal.

"Abe's absence could affect the Bank of Japan's ultra-loose monetary policy, which is not positive to the stock market," said Morita.

The benchmark index rose more than 1% earlier as heavyweight chip-related stocks tracked overnight Wall Street gains, after less hawkish comments from Federal Reserve officials eased concerns about U.S. recession.

Heavy weight chip-related shares advanced, with Tokyo Electron's rising 1.7% and and Advantest climbing 1.82%.

Non-ferrous metals makers rose 2.43% after Reuters reported that China will set up a state infrastructure investment fund worth 500 billion yuan ($74.69 billion) to spur infrastructure spending.

Sumitomo Metal Mining jumped 5.2% and Mitsubishi Materials advanced 2.88%.

Seven & i Holdings cut gains to end 0.65% lower even after convenience store chain raised its full-year profit forecast.

Kewpie lost 3.32% after the mayonnaise maker reported declines in profits after raising prices. (Reporting by Junko Fujita in Tokyo; Editing by Arun Koyyur )