An Indiana judge has taken an unusual step and temporarily barred Starbucks from closing 77 failing Teavana stores in Simon Property Group malls because the real estate giant was less able to handle the financial pain.

Starbucks said in July it planned to shutter its 379-store Teavana operation — but Simon rushed to court to block 77 stores in its malls from going dark — claiming such a move by a high-profile tenant could spark other stores in its malls to close.

Starbucks, after trying to turn around its stumbling tea chain, said last August it was pulling the plug on Teavana.

It wanted to close all the stores by the end of the year.

But Indianapolis-based Simon, in an environment where hundreds of stores across the country are closing, rushed to a local court to ask Judge Heather Welch to stop the store closing.

Welch, in a 55-page order, found that the very profitable Starbucks could absorb the financial hit — estimated by Starbucks to be $15 million over five months — better than Simon could. The mall operator did not provide an estimate of how much the closings of the Teavana stores would hurt them.

The case is being closely watched by retailers and landlords alike amid a retail meltdown that has resulted in a record number of bankruptcies this year.

The retail failures have left landlords scrambling to find new tenants and retailers in the difficult position of breaking their leases.

Still, it is rare that a judge orders a retailer to keep stores open, retail experts said.

“I’m somewhat shocked by the ruling,” said real estate lawyer Joshua Stein. Welch “catalogues every possible detriment to Simon as a result of having vacant space,” Stein said, adding, “That’s part of a job description of owning real estate. You deal with it and don’t get injunctions to have your tenant continuing to operate.”

Other industry experts, who did not want to be identified, said the ruling will send a chill down the spines of distressed retailers.

“If you are a tenant that has to close a bunch of stores that are based in malls,” said one source, “you are pretty scared after this ruling.”

Welch admitted that “no court has ever entered preliminary or permanent injunctive relief to specifically enforce a continuous operations covenant against a non-anchor tenant” — but she did so anyway.

“We are disappointed in the judge’s ruling and will continue to focus on finding a resolution,” Starbucks, which has a market cap of $81 billion, said in a statement, noting that it is not clear whether it will appeal — or even if it is permitted to do so.

Simon’s vacancy rate as of Sept. 30 was 4.7 percent — slightly below the 4.8 percent national vacancy rate for all malls, according to JLL data.

Simon argues that if Starbucks is allowed to “prematurely” break its lease, it could be forced to fill the vacancies with “less creditworthy tenant(s)” or less desirable tenants “who will only agree to less desirable lease terms, and/or a shorter-term lease,” according to the court filings.

Industry sources suggested that other mall operators may now challenge Starbucks’ plans to close Teavana stores in their shopping centers.

Shares of Simon Property Group, a $52 billion company, gained 60 cents on Friday, to $162.35.