Over the last 30 years, a near constant flow of cash has inundated China and other emerging markets. It has lifted those economies, pulled hundreds of millions of people out of poverty, and dictated corporate expansion plans worldwide.

That wave is now ebbing.

This year will see the first net outflow of capital from emerging markets in 27 years, according to the Institute of International Finance, a trade group representing international bankers. The group expects more than $500 billion worth of cash previously invested in things like Chinese factories, Brazilian government bonds, and Nigerian stocks to cascade out of such markets this year.

What’s going on? In a word: China.

In a profound change of narrative for both the global economy and markets that are closely tied to it, the story of fast Chinese growth—a story that has soothed investors and corporate managers around the world since the 1980s—is looking increasingly tough to square with the evidence. And it’s even tougher to imagine anything else like China—a billion new consumers joining the global economy—emerging any time soon.

GDP growth in the People’s Republic fell to 7% per year in the second quarter, according to official numbers—some of the most sluggish growth since the 2008 global financial crisis.

And most analysts say even those numbers should be taken with a handful of salt. For instance, economic forecasting firm Capital Economics estimates that GDP in the first half of 2015 grew not at 7% year-over-year, but at just above 4%.

Of course, the slowdown in China isn’t confined to China. Over the last 30 years, countries worldwide have built their economies to service the needs of the People’s Republic. Brazil would be a case in point.

Weak Chinese demand hurts China’s suppliers…

The South American giant has done a brisk business digging up and selling China the iron needed to feed booming steel mills. (Brazil is the world’s second largest iron ore exporter, behind Australia.) But Chinese steel mills aren’t roaring like they used to. Crude steel production fell 2% during the first eight months of the year, a decline unprecedented in data going back roughly 20 years. (In the chart below, gaps in the data relate to the Chinese lunar new year, when data usually aren’t published.)

As Chinese steel plants cooled, iron ore prices fell sharply. At roughly $55 a tonne, iron ore prices are down 60% from where they were at the end of 2013. And as prices for iron plummeted, so did revenues of big iron-ore exporters such as Brazil.

…and that hurts their currencies

Now, to purchase iron ore from Brazil, you need Brazilian currency. During good times, that pushes up demand for the Brazilian real. But if demand for Brazilian iron ore—or other commodities—falls, so should demand for the real. And that’s exactly what we’re seeing. The real has fallen roughly 40% against the dollar over the last two years.

And it’s not just Brazil. Similar dynamics are at play throughout emerging markets that have relied on commodities exports, often to China.

This is a big problem for a whole bunch of reasons. But it’s especially worrisome for investors who have, in recent years, lent a ton of hard currency—US dollars—to companies and governments in those countries by buying dollar-denominated bonds from them. As the currencies of these countries get weaker, it takes more and more reals—or ringgit or pesos or rands—to acquire the dollars needed to repay those bonds.

Worried that they won’t get paid back, people who hold those bonds have been selling them. That pushes up bond yields, which are the borrowing costs. For economies that are already struggling, higher borrowing costs are yet another blow.

Feedback loop

Now, these weak emerging-market currencies can also have a knock-on effect on richer nations. In particular, the US.

For instance, as the Chinese economy has slowed, demand to invest there has slowed, and so the Chinese yuan has weakened too. So much so that China effectively devalued it on Aug. 11, in a move that sent shockwaves through global markets (and just the latest chapter in a long-running saga for the yuan and dollar, as the chart below shows).

Now, when China’s currency was strengthening, the Chinese central bank prevented it from strengthening too much by buying US dollars and selling freshly printed yuan. It would then take those dollars—its foreign-exchange reserves—and sock them away into safe, dollar-denominated investments, mostly US government bonds. And its pile of these bonds grew steadily—up until last year:

What does this mean? Well, for starters, it means that on the margin China will be less of an aggressive buyer of US government securities. That’s no small thing, as the country is the largest creditor to the US. In theory, the drop in demand for US debt could at some point make it more expensive for the US to borrow, though that isn’t happening so far.

But the broader point is that this marks a new phase for the global economy. For nearly 30 years, China has bulked up by digesting tons of commodities from the world’s emerging markets and turned them into exports, and in the process has become a key creditor to the world’s largest consumer economy, the United States. All of that is changing now, and nobody is quite sure how it will play out.