On a sweltering night this February, the world’s No. 2 exporter of liquefied natural gas didn’t have enough energy left to keep its own citizens cool.

A nationwide heat wave in Australia drove temperatures above 105 degrees Fahrenheit around the city of Adelaide on the southern coast. As air-conditioning demand soared, regulators called on Pelican Point, a local gas-fueled power station running at half capacity, to crank up.

It couldn’t. The plant’s operator said it wasn’t able to get enough natural gas quickly to run its turbines fully. At 6:03 p.m., regulators cut power to 90,000 Adelaide homes to prevent a wider blackout.

Resource-rich Australia has an energy crisis, one that offers lessons for America as it prepares to vastly increase natural-gas shipments abroad.

Australia now exports so much liquefied natural gas, or LNG, it may overtake No. 1 exporter Qatar within several years. It exported 62% of its gas production last year, according to the BP Statistical Review of World Energy.

Yet its policy makers didn’t ensure enough gas would remain at home. As exports increased from new LNG facilities in eastern Australia, some state governments let aging coal plants close and accelerated a push toward renewable energy for environmental concerns. That left the regions more reliant on gas for power, especially when intermittent sources such as wind and solar weren’t sufficient.

Shortages drove domestic gas prices earlier this year in some markets in eastern Australia to as high as $17 per million British thermal units for smaller gas users such as manufacturers. On the spot market, gas prices have gone from below $1 in 2014 to roughly $7 today—well above the roughly $3 that prevails in the U.S.—causing havoc around the country.

In March, Australia’s largest aluminum smelter cut production and laid off workers because it said it couldn’t secure enough cheap energy. During one blackout last year, some families lost embryos in an in-vitro-fertilization clinic with no backup generation, according to a government-commissioned report. In February, some tuna fishermen watched catches rot because freezers shut off.

The blackouts have been severe enough to catch the attention of Tesla Inc. Chief Executive Elon Musk, who said last week he agreed to build a giant battery system in the state of South Australia, where Adelaide is the capital city, to store power from a wind farm. Such a system could provide electricity during shortages.

Prime Minister Malcolm Turnbull, in an emailed response to Wall Street Journal questions, blamed previous Labor governments. Mr. Turnbull, of the center-right Liberal Party, said “gas export licenses were issued without regard to the consequences for the domestic market,” and, “as a result, at a time of record gas production we have had the prospect of a shortage of domestic gas on the east coast.”

The Labor Party says that when the LNG-export plants were approved, the industry said sales abroad wouldn’t impact domestic gas supply because it was developing new sources of gas. “It is clear that those assurances haven’t come to pass,” said Mark Butler, the Labor lawmaker who is currently its spokesman on energy. “If we had our time again, we would have put in place a national-interest test,” he said. Such a test insures domestic needs are protected.

Australia’s plight is less likely in America, which is experiencing a gas glut and is boosting exports. The first LNG-export terminal in the lower 48 states opened in Louisiana last year, allowing exports by ship in addition to existing pipelines to Mexico and Canada. Energy Secretary Rick Perry said at his Senate confirmation hearing he wanted to boost natural-gas exports.

The U.S. is on track to become the world’s No. 3 LNG exporter behind Qatar and Australia by 2020, according to the U.S. Energy Department.

Unlike Australia—which has plentiful gas supplies in its west but no pipelines to get them to its gas-starved east—the U.S. has a large pipeline grid, making it easier to move supplies during shortages. It also has largely avoided the kind of long-term export contracts that trapped Australian companies into giving foreign buyers priority.

Still, Australia’s gas pains offer a case study in what can go wrong in committing to expanding exports at the same time as other steady power sources are shutting down, said Michael Webber, deputy director of the Energy Institute at the University of Texas at Austin. “We have more options” in America than Australia, he said, but “there’s always a risk that markets will behave in a different way than we anticipated.”

“There’s no one country that has mastered this,” Mr. Webber said. “We’re all learning from each other.”

Until the 2000s, Australia was a minnow in international energy markets. It had major gas deposits off its northwestern coast, but coal remained its dominant fuel source.

New gas source

Geologists had suspected there was methane gas buried in Australia’s vast coal seams. When energy prices climbed with Chinese demand, companies including BG Group PLC, now owned by Royal Dutch Shell PLC, rushed to extract this “coal-seam gas”—a process that involves pushing gas out of seams, sometimes through hydraulic fracturing, or “fracking”—in Australia’s east.

ConocoPhillips bought a 50% stake in an Australian coal-seam-gas venture for $8 billion in 2008. In 2010, Shell and PetroChina Co. in a $3 billion deal acquired coal-seam-gas producer Arrow Energy, which had a market value of $10 million a few years earlier.

Producers say they concluded the only way to justify the cost of extracting coal-seam gas was to sell it abroad, where demand was higher and customers would agree to long-term contracts. They also needed money to build terminals on the east coast to convert gas into liquid for shipping.

In 2009, BG Group and Adelaide-based Santos Ltd. signed 20-year export deals, the first of a string of long-term export contracts that coal-seam-gas concerns in Australia would sign.

In a 2009 report, the northeastern Queensland state’s government warned of “a real problem that the availability of gas in the ground may not translate into gas supplied to the domestic market.” It suggested requiring energy companies keep up to 20% of production for domestic users.

Australia’s energy companies argued such “gas reservation” policies would deter investment needed to boost supply. Many politicians emphasized how LNG projects would create jobs in the aftermath of the global financial crisis.

Queensland didn’t institute a gas-reservation plan. Its government now says it couldn’t have predicted all the forces creating current shortages.

Western Australia state did implement a similar plan years before for its offshore gas, avoiding local gas shortages. The plan also applied to exports from LNG terminals added on the west coast after 2009.

In Australia’s east, three terminals were built off Gladstone in Queensland.

As gas production increased, Australia cut back on coal, whose use had put it among the world’s biggest greenhouse-gas emitters per capita. Coal-fueled plants were shut down without comprehensive plans for replacing them with other power sources.

South Australia and Queensland, in 2014 and 2015, set targets to get 50% of their electricity from renewable sources such as wind and solar. Gas, the argument went, would help fill the gap when renewable power wasn’t sufficient.

Some prospective new gas sources in the east were being shut down, with New South Wales placing a moratorium on fracking in 2011 and later freezing new exploration licenses for coal-seam gas. Victoria in March this year banned fracking and new coal-seam-gas development.

Santos and its partners weren’t able to pump as much gas as expected and began signing third-party supply contracts, including from other gas producers and electricity companies to meet export obligations, adding to factors driving up domestic prices.

As prices rose, some manufacturers using gas, such as fertilizer makers, publicly threatened to move operations abroad. Power plants relying on gas—currently about 25% of Australia’s power grid—raised rates.

“Santos has been singled out as almost the sole cause” of Australia’s gas problems, Santos Chairman Peter Coates told shareholders in May. Coal-seam gas could underpin Australia’s long-term needs with more investment and never would have been developed without foreign buyers, he said. “The gas would still be sitting in the ground.”

Gladstone, the city with the three new LNG-export facilities, has been among areas most affected. It is home to manufacturers that use gas, including Australia’s largest aluminum smelter, a Rio Tinto PLC plant that once distributed beer-can holders reading: “Proudly Australian, operating beyond 2030.”

In March, Rio Tinto cut 14% of the smelter’s production and laid off 100 workers, saying it couldn’t secure enough inexpensive energy. Rio Tinto CEO Jean-Sébastien Jacques in May said: “The price was so high that it didn’t make any sense anymore for us to produce.”

Kirsty Callander said her Fit Life smoothie-and-snack bar in Gladstone has seen business shrivel since the smelter layoffs. “I think Australia should keep what’s ours,” she said, “and get the jobs and money coming here.” Down the road at Tannum Meats, store manager Nathan Lynn said he once sold a dozen rib-eye steaks a day and now is lucky to sell that in four days.

In February, regulators ordered another aluminum smelter, in New South Wales, to cut production to prevent power outages in the state, which includes Sydney.

Repeated outages

Outages have become a familiar gas-crisis byproduct, including one last September in which 1.7 million households and businesses in South Australia state lost power after tornadoes damaged lines supplying power from Victoria. South Australia was relying on other states for electricity because volatile gas prices and other issues had forced its generators to cut capacity. Power wasn’t fully restored for 12 days.

In the week that Adelaide’s February blackout cut power to 90,000 homes, five ships left Gladstone carrying out 314,000 tons of LNG altogether, according to the port operator. That’s enough to generate electricity for roughly 750,000 Australian homes for a year, according to calculations for the Journal by the Australian Bureau of Statistics.

The Adelaide blackout traced to 2015, when the Pelican Point gas-fired power plant’s owner, Engie SA of France, mothballed one of its two turbines, saying it was too expensive to run at prevailing gas prices.

When Australia’s electricity overseer, the Australian Energy Market Operator, ordered Pelican Point to fire up its second turbine that hot February day, Engie initially said it wasn’t available. When the regulator insisted, Engie said it couldn’t move quickly without gas-supply contracts.

Engie declined to comment about the blackout. In a media statement afterward, it said: “There is no commercial rationale to operate the second Pelican Point unit in the current market environment in [South Australia] for a small number of days across the year.”

Engie in March agreed to restart the second turbine after Origin Energy Ltd. , which operates one of the Queensland LNG plants, committed to provide gas to Pelican Point and buy some of its electricity.

Prime Minister Turnbull that month urged producers to reserve more gas for the domestic market. He declared in April he would invoke little-used trade powers to block some exports until local needs were met; the measures went into effect July 1.

The energy regulator in June said the market and government response should help secure the power grid, though it “remains susceptible” to extreme summer conditions.

South Australia and Queensland are promising to open more land to gas development. Shell has reduced exports from one Australian LNG facility to supply more gas locally and recently signed supply contracts with utilities, including a short-term deal with Engie.

Companies’ flexibility to make such concessions is constrained by overseas contracts, industry analysts say. Without more gas production or faster development of other power sources, many say, Australia faces more shortfalls.

“It takes long lead times to bring on new gas developments,” said Saul Kavonic, a Perth-based analyst at energy consultancy Wood Mackenzie. “You can’t just press a magic button and fix it overnight.”

Meanwhile, budgets of Australians such as retiree Lynda Pearce, 68, are feeling the shortage’s impact. “I’m really worried about what’s going to happen. It’s sort of like waiting for a bomb to explode,” said Ms. Pearce, who in a Gladstone suburb has seen her power bill go up around 6% in three months.