Macy’s (M) is suing Martha Stewart Living Omnimedia (MSO) for allegedly breaching an exclusive contract by agreeing to sell certain products to J.C. Penney (JCP).

The media and merchandising company raised $38.5 million by selling a 16.6% stake to J.C. Penney in December and providing the department-store chain with two board seats.

But Macy’s says that agreement breaches an earlier agreement that has allowed it to exclusively sell a Martha Stewart line in 2007, a five-year deal slated to expire at the end of this year.

In December, Macy’s said it would review its Martha Stewart product line for “potential changes” due to the “proliferation of Martha Stewart-branded product in the marketplace.” On Monday, it said it would seek an order to seal the lawsuit.

The feud has the potential to really impact all three bottom lines, as both J.C. Penney and    Macy’s rely largely on home goods to drive traffic and sales, and Martha Stewart has become increasingly dependent on merchandising.

J.C. Penney CEO and former Apple (AAPL) executive Ron Johnson, who is reportedly readying to cut thousands of jobs nationwide as part of the company’s turnaround plans, had hoped the deal would give a major boost to the aging store’s troubled housewares business.

Martha Stewart living is expected to make more than $200 million over its 10-year contract with J.C. Penney. A spokeswoman told The Wall Street Journal in December that the products sold in both retail chains would differ.

Shares of Martha Stewart fell nearly 3% in after-hours trade on Monday, while J.C. Penney and Macy’s slipped marginally.  

Follow Jennifer Booton on Twitter at @Jbooton