Calling it a bittersweet day, U.S. Bankruptcy Judge Martin Glenn announced today before a packed courtroom during proceedings involving Borders' liquidation some stores may be spared through a sale to Books-a-Million.

Glenn said a last-minute offer from Books-a-Million may save 30 Borders stores and as many as 1,000 to 1,500 jobs.

Borders was still planning to proceed Thursday in seeking court approval to liquidate, closing most of its 399 stores.

This is a bittersweet day, said Judge Glenn. There are a lot of sad people around the country, a lot of sad people in the corporate headquarters. But there has been a late-breaking development.

Based in Birmingham, Alabama with more than 200 stores in the Southeast, Books-a-Million has made an offer to buy 21 Borders superstores and nine smaller stores. Seven of the 30 stores in located in Pennsylvania. The superstore locations include Atlantic City, N.J., and Waterford, Conn.

The deal still must be approved.

The judge told Borders to get the offer from Books-a-Million in writing, and a scheduled hearing was put on hold so the company could have time to document terms of the last-minute offer.

Based in Ann Arbor, Mich., Borders filed for bankruptcy in February. The nation's second-largest bookstore tried to find a buyer to keep all or some of its 399 stores open but a deal never materialized, and the company decided to liquidate. Borders began negotiating with Books-a-Million last week, in the effort to keep some stores open, but a deal wasn't reached.

Books-a-Million is a publicly traded company. Its stock (BAMM) rose three percent on the news to $3.05 in trading Thursday.