Tempur-Pedic International Inc. agreed to buy Sealy Corp. for about $229 million, combining the two biggest publicly-traded mattress companies and ending a more than 20-year run of private-equity ownership.

The offer of $2.20 a share is 2.8 percent more than Sealy’s closing price Wednesday. Tempur-Pedic, a pioneer of memory-foam mattresses based in Lexington, Kentucky, will assume or repay all of Sealy’s outstanding and convertible debt, for a total deal value to $1.3 billion, according to a statement Thursday.