A pair of shopping-mall giants is weighing whether to invest in bankrupt teen retailer Forever 21, sources told The Post.

The fast-fashion pioneer, which filed for bankruptcy protection on Sunday morning, had recently tried to cut a deal in which its two largest landlords, Brookfield Property and Simon Property, would take an ownership stake in the chain, according to the sources.

The idea, according to insiders, is to keep the lights on.

“If the landlords can keep these stores operating even at reduced rents, it gives them more control in how to re-purpose the spaces,” said one source.

The nationwide closure of 178 locations in Forever 21’s chain of 541 US stores — some of which are as large as department stores — would leave gaping holes at shopping malls just as the holiday season gets underway.

“The real motivation is that they don’t want that level of vacancy sweeping out into their malls.” a second source noted.

Negotiations between Los Angeles-based Forever 21, Brookfield, and Simon reached an impasse over the weekend, and are “dead for now,” according to a source briefed on the situation.

Nevertheless, another source with knowledge of the situation said the talks could still be revived in the coming days or weeks.

“I wouldn’t count them out yet,” the source said.

Reps for Simon, Brookfield and Forever 21 didn’t respond to requests for comment.

Forever 21 is privately owned by husband-and-wife team Do Won Chang and Jin Sook Chang. Their children also work for the retailer, whose growth spurt began more than a decade ago, fueled by demand for its $9.90 T-shirts, $25 jeans and $20 hoodies.

In talks with landlords, Do Won Chang had hoped to retain a share in the company, Bloomberg reported Sept. 17.

Forever 21 is planning to close 350 of its 800 stores worldwide, including most of its operations in Asia and Europe, according to court documents. But it did not disclose which stores were on the chopping block. It has lined up $350 million in financing from JPMorgan and TPG.

Three years ago, Simon and mall operators GGP — which is owned by Simon now — rescued teen chain Aeropostale out of bankruptcy rather than face 740 stores going dark.

“Buying Forever 21 out of bankruptcy could be the lesser of two evils for the mall owners,” said a source.

Simon is owed $8.1 million and is the landlord to 99 Forever 21 stores, while Brookfield is owed $5.3 million, according to public filings.

The first Forever 21 store opened 35 years ago in Los Angeles, and the family quickly expanded with the rise of fast fashion. But its big, boxy stores began to flounder as malls began to fall out of favor and consumers shopped more online.

“They kept focusing more on teens in recent years,” alienating older shoppers in their 20s and 30s, said retail consultant Gabriella Santaniello.

As the company’s financial challenges increased, she added, sales staff were let go and “it became a real unpleasant place to shop because you couldn’t get any help and the stores were disorganized.”