China has lost its crown as the United States' biggest overseas creditor. That title now belongs to Japan.

Beijing has been dumping U.S. government debt to prop up its currency. China uses the dollars it gets from selling U.S. Treasuries to buy the yuan, which has sunk to an 8-year low as the world's second largest economy slows.

China's huge holdings of U.S. debt fell to $1.12 trillion at the end of October, their lowest level in more than six years, according to U.S. Treasury Department data. Japan held $1.13 trillion.

Both countries offloaded Treasuries during the month, but China dumped far more: its holdings dropped by $41.3 billion, while Japan's fell by just $4.5 billion.

Related: Trump attacks China on trade but misses the mark

China's willingness to lend vast sums to the U.S. government has drawn a lot of attention in recent years. Since September 2008, the Treasury Department has ranked it as the biggest foreign creditor to the U.S., with the exception of one month in early 2015 and again with its latest update.

The situation has raised concerns about Beijing's leverage over the United States. President-elect Donald Trump has claimed the opposite, suggesting it gives the United States "a lot of power" over China.

Experts say the reality is more complicated, arguing that the debt relationship binds the world's two largest economies closely together. Trump has suggested he will take a more confrontational stance toward China on trade, threatening to slap tariffs of as much as 45% on Chinese goods.

Related: 8 reasons why starting a trade war with China is a bad idea

For years, China spent trillions of yuan buying Treasuries as a way of stopping its currency from getting too strong even as its economy grew rapidly. That made China's exports more competitive, but it also helped to keep interest rates in the U.S. lower than they would have been.

But as China's economy has slowed in recent years, huge sums of money have been flowing out of the country, putting downward pressure on the yuan. The surge in the dollar since Trump's election victory has piled on the pressure.

Related: Who owns America's debt?

Beijing has been selling some of its enormous stockpile of foreign exchange reserves, much of it U.S. government debt, in order to buy yuan. It wants to avoid a repeat of the sudden plunges in the currency that panicked markets in August 2015 and January 2016.

China's foreign currency war chest fell to its lowest level in more than five years in November.

Japan isn't the biggest single holder of U.S. debt. At the last count, the Federal Reserve had about $2.5 trillion.