TOKYO, Aug 23 (Reuters) - Japan's Nikkei share average posted modest gains on Wednesday, snapping five straight days of losses that marked its longest losing streak since April 2016.
The market was helped by a rebound in Wall Street shares overnight, but the main index pared early gains following comments from U.S. President Donald Trump on the NAFTA trade treaty and his plan to build a border wall.
The Nikkei ended 0.3 percent higher at 19,434.64 points.
Upbeat comments from top U.S. Republicans in Congress on tax reforms and the debt ceiling debate had helped the S&P 500 rebound from a six-week low.
Yet optimism was undermined after Trump told a rally that he would build a border wall with Mexico even if he has to shut down the government to secure enough funding.
Trump also said he might terminate the NAFTA trade treaty with Mexico and Canada after three-way talks failed to bridge deep differences.
That added to jitters ahead of an expected second round of economic and trade talks between Japanese and U.S. officials in coming months.
Japanese investors are also keeping an eye on tensions between the United States and North Korea, after the United States and South Korea began joint computer-simulated military exercises on Monday.
"As long as Trump doesn't say something provocative, the market should stay calm for now," said Kazuhiro Takahashi, an equity strategist at Daiwa Securities.
The broader Topix rose 0.3 percent to 1,600.05 but turnover on the main board remained subdued, with only about 1.9 trillion yen changing hands, more than 10 percent below the recent average.
Sensor maker Keyence rose 4.5 percent, extending its solid rally on the back of strong earnings and after some brokerage raised their target price for the stock.
Toshiba Corp rose 4.3 percent on a media report that the company is prioritizing talks with Western Digital on the sale of its chip unit.
(Editing by Michael Perry and Kim Coghill)