In plenty of time for Martha Stewart's June 7 sentencing hearing, rebounding discount retailer Kmart (NASDAQ:KMRT) has dropped its lawsuit against the domestic diva's eponymous media company and extended their partnership agreement through 2009.

Kmart had accused Martha Stewart Living Omnimedia (NYSE:MSO) of overcharging it for exclusive rights to sell housewares and other products under the Martha Stewart Everyday label. It charged in a February lawsuit, filed in bankruptcy court, that MSO was trying to squeeze more fees out of the retailer than it was entitled to.

Even though the joint release has Kmart planting a big, wet kiss on Martha's CEO, Sharon Patrick, the new contract conditions mean Martha Stewart Living will receive $4.5 million less than it contended it was owed under the previous contract. Further, Kmart is required to spend a reduced amount on advertising in MSO's media properties.

Still, it's a shot in the arm for Martha's company, which has been beset by bad news due to its founder's legal troubles (though it's still up 80% from when it was first recommended by David Gardner in Motley Fool Stock Advisor in 2002, compared to the S&P 500's 36%). Yet it's an even better deal for Kmart.

The amended contract keeps a minimum guaranteed payment for overall sales, but eliminates minimum payments in each product category, which was the source of the conflict. It also expands it to cover new product categories, including ready-to-assemble furniture.

The Michigan-based discounter emerged from bankruptcy protection last May and posted its first profit last month. The Martha Stewart brand, even with her having been found guilty of obstructing a stock-sale investigation, has been an important source of revenues for Kmart. Understanding the loyalty of the brand's fans -- according to America's Research Group, only 5% to 7% of the customers who purchased Martha Stewart Living products at Kmart no longer buy them from there, a figure it called "insignificant" -- it was able to use that vulnerability to extract better terms.

MSO's merchandising division relies on Kmart for about 85% of its revenues and about 22% of its overall $246 million in sales. The brand accounts for about 5% of the retailer's revenues, or about $1.2 billion, according to UBS Investment Research.

Kmart has stood by Martha Stewart through her arrest, indictment, trial, and now her sentencing. With some legal experts anticipating her to receive 37 to 46 months in jail, it looks like Kmart will be standing by her release, too.

Check out Motley Fool Stock Advisor risk-free for six months.

Fool contributor Rich Duprey has visited Martha Stewart's childhood hometown of Nutley, N.J., and has even shopped in Kmart on occasion, but he does not own any of the stocks mentioned in this article.