TOKYO, July 20 (Reuters) – Japanese stocks ended weaker on Friday as an earlier decline in the Chinese yuan rekindled worries about the stability of the world’s second largest economy, which faces rising risks from a major trade conflict with the United States.

Japan’s Nikkei share average fell 0.29 percent to 22,697.88 while the broader Topix shed 0.26 percent to 1,744.98. However, both indexes posted their second straight weeks of gains.

The losses were driven by selling in Nikkie futures after the yuan weakened below 6.8 per dollar in the onshore trade for the first time in a year. However, a bounce in the yuan later on suspected support from Chinese state banks helped the Nikkei pare some of its losses.

“Further falls in the yuan will heighten worries about capital flights like the one we saw in 2015-16. So there is knee-jerk selling,” said Hideyuki Ishiguro, senior strategist at Daiwa Securities.

Steel makers, non-ferrous metal companies and shippers – the regular victims of trade war worries – led the losses with falls of 1.3 percent, 1.7 percent and 1.4 percent respectively.

Kobe Steel dropped 2.3 percent after the company was indicted by prosecutors over a data tampering scandal that shook the company last year.

Insurers fell 1.1 percent as their earnings are seen squeezed by continuous flattening in the yield curve.

Semi-conductor related shares came under pressure after Taiwan’s TSMC, the world’s largest contract chipmaker, trimmed its annual revenue and capital spending estimates on bleak demand from smartphone and cryptocurrency mining industries.