Since before it was even really a settlement, Gladstone — a town of 65,000 people at the southern end of Australia’s Great Barrier Reef — has lived and died on the global commodity trade.

In 1859, the first major shipment over the sandbars guarding its harbor carried 60 three-year-old horses bound for India. Now one of the world’s biggest fossil fuel ports, thanks to decades of voracious demand for steelmaking coal and gas from an industrializing Asia, it is facing the biggest test yet: Whether it can reinvent itself for a world switching toward clean power.

The numbers look daunting. The most likely outcomes are either that the energy transition fails, or it succeeds and leaves Gladstone and Australia — the world’s biggest net exporter of fossil fuels after Russia, the U.S., Saudi Arabia and Indonesia — worse off. The outcome will be an early indicator of the struggles economies will face over the coming century, as clean energy and geopolitical rivalries remake trade and diplomacy.