China, maker of about half the world’s steel, is exporting a lot less of the metal as government-ordered closures of illegal plants tighten supply and improving local demand spurs mills to sell more at home. At the same time, its shipments of aluminum are roaring ahead.

China’s overseas sales of steel fell to 6.81 million metric tons in June from 10.94 million tons a year earlier, which was the second-highest monthly volume on record, and 6.98 million tons in May, according to customs data Thursday. Over the first six months, exports slumped 28 percent to 40.99 million tons, the agency said.

In recent years, the nation has drawn scrutiny for excessive production, soaring exports, and sinking prices. Last week’s Group of 20 meeting in Germany saw global steel overcapacity high on the agenda as the Trump administration weighs punitive tariffs to protect the American Rust Belt.

Meanwhile, China’s steel industry seems to be reversing course, buoyed by economic stimulus, capacity shutdowns and speculative interest in the metal. Reinforcement bar, a benchmark product used in construction, has rallied 26 percent in Shanghai this year.

“Lower exports are due to strong demand domestically and also prices, so producers don’t have the motivation to export,” Yi Zhu, an analyst with Bloomberg Intelligence, said ahead of the data’s release. Zhu said she’s just returned from a tour of mills in China, where there are indications of a shortage of some steel products, leaving little room for foreign sales.

Mirroring its concerns over steel, the Trump administration has also opened an investigation into an influx of foreign aluminum. China, the world’s biggest producer of the lightweight metal, has again been the target of criticism for creating a global glut.

The nation’s aluminum exports in June jumped 21 percent to 460,000 tons from a year earlier, customs data show. Over the first six months, volumes increased 5.9 percent to 2.41 million tons. Prices, which have climbed 12 percent in London this year, have helped spur an expansion in output that the government is trying to rein in via capacity cuts.

Robust steel demand is boosting China’s imports of iron ore. Inbound shipments of the raw material rose 9.3 percent to 539 million tons in the first half from a year ago, according to the customs data. Shipments in June were 94.7 million tons from 91.52 million tons in May and 81.63 million a year ago.