In December 2011, Ron Johnson hailed J.C. Penney Co.’s $38.5 million investment in Martha Stewart Living Omnimedia Inc. as “transformational.”

Almost two years later, Johnson is gone as chief executive officer and J.C. Penney on Tuesday rolled back an agreement tied to the investment in the homemaking maven’s company. Under an amended deal, the partnership will end in June 2017 instead of 2021 and the parties will stop making products in categories at the center of a lawsuit brought by Macy’s.

J.C. Penney also will give back the 11 million shares it bought for $3.50 each and the right to board representation at Martha Stewart Living, it said in a statement.

Macy’s sued the companies last year, saying it had exclusive rights to sell Stewart-designed items in categories including bedding, bath and cookware. After the suit, J.C. Penney rebranded the Stewart goods in those disputed categories “JCP Everyday.” Macy’s then pushed for the sales of those items to be stopped because they were designed by Stewart’s company.

The new agreement between J.C. Penney and Martha Stewart Living, which includes the continuation of the department-store chain carrying Stewart-branded window treatments and holiday goods, hasn’t persuaded Macy’s to drop its case.

The announcement showed the old deal was “illegal” and Macy’s case for damages remains before the court, Jim Sluzewski, a spokesman for the Cincinnati-based chain, said in an emailed statement.

“We are not dropping our claims,” Sluzewski said.

J.C. Penney rose 7.48 percent, or 49 cents, to $7.04 on Wednesday. The shares have sunk 67 percent this year, compared with a 23 percent gain for the Standard & Poor’s 500 Index. Martha Stewart Living, based in New York, fell 1 cent to $2.37, and has fallen 2.9 percent this year.

The century-old retailer is trying to revive sales after revenue collapsed during Johnson’s failed attempt to transform the chain into a destination for younger and wealthier shoppers. During his 17-month tenure, he alienated longtime customers by cutting back on discounting and swapping out well-liked brands for new merchandise. He also spent heavily on remodeling more than half the chain’s 1,100 stores.

Those higher costs coupled with sinking sales led to losses and an eroding cash position. Since reclaiming the CEO job in April, Mike Ullman has raised $3.89 billion to shore up the chain’s balance sheet.

J.C. Penney reached the new agreement with Stewart’s company as it works to revamp its home department. The “JCP Everyday” items had been heavily discounted for months as the retailer tried to liquidate excess merchandise.

“We are moving forward with the successful parts of Martha Stewart,” said Kristin Hays, a spokeswoman for J.C. Penney. She declined to comment on the Macy’s statement or the financial terms of the new deal.