NEW YORK (AP) — Macy's Inc. is suing rival retailer J.C. Penney Co., claiming Penney's bid to sell products by Martha Stewart Living is a breach of an exclusive contract held by Macy's and could cost it potentially billions in sales.

In the complaint filed Thursday in the Supreme Court of the State of New York, Macy's claims that J.C. Penney entered into an unlawful contract with Martha Stewart Living to sell some of its home products at its stores starting next February.

That agreement, announced last fall, represents a breach of contract because Macy's already has a deal in place with options to exclusively sell Martha Stewart goods through 2018, according to the lawsuit.

The pact between Macy's and Martha Stewart, which goes back to 2007, gives Macy's, among other rights, exclusive rights to sell Martha Stewart products in categories including housewares, bedding, bath and cookware, Macy's said.

"J.C. Penney wanted to rob Macy's of market share and destroy the competitive advantage that it enjoys as a result of its existing exclusive agreement with (Martha Stewart Living)," Macy's claims in the lawsuit.

As a result, Macy's contends, J.C. Penney induced Martha Stewart Living into breaching its contract with Macy's. And that has caused Macy's to incur "substantial damages and threatens to inflict incalculable further harm on Macy's. Billions of dollars of sales are involved," according to the lawsuit.

Macy's, which is based in Cincinnati, seeks unspecified damages and an order blocking the Penney-Martha Stewart deal.

Last month, a New York judge issued a preliminary injunction that temporarily blocks Martha Stewart Living from selling the products covered in its agreement with Macy's at Penney stores. Martha Stewart Living has said it does not think its agreement with Macy's was breached.

In a statement, Macy's said it decided to sue Penney to protect its rights under its pact with Martha Stewart Living.

It declined to comment further.

J.C. Penney acquired a 16.6 percent stake in Martha Stewart Living and announced plans in December to open Martha Stewart mini-shops beginning next year. It has been counting on the popularity of the brand as part of its efforts to help revitalize its business under new CEO Ron Johnson.

A representative for J.C. Penney, which is based in Plano, Texas, said the company does not comment on pending litigation.

Macy's shares ended regular trading up 20 cents at $38.74 on Thursday. The stock added 2 cents to $38.76 in aftermarket trading.

Shares of J.C. Penney slipped 8 cents to $24.23 in extended trading after rising 64 cents, or 2.7 percent, to $24.31 during the regular session.

New York-based Martha Stewart Living Omnimedia Inc. finished regular trading up 4 cents at $3.12. They were unchanged afterhours.