Japan surpassed China in June as the top holder of U.S. Treasurys after raising its holdings to a nearly three-year high, as the trade war between the world's two largest economies intensified.

Holdings of U.S. bonds, bills and notes were increased by $21.9 billion to $1.12 trillion, the highest level in more than 2½ years, according to data released by the Treasury Department on Thursday. Meanwhile, China's ownership rose for the first time in four months to $1.11 trillion, up by $2.3 billion.

The last time Japan held the position as America's largest foreign creditor was May 2017. From January to May 2017, Japan held more Treasurys than China, data showed.