Mercer Foods LLC owned its headquarters and factory in Modesto, Calif., for 23 years. In February, the freeze-dried food company sold the real estate to LCN Capital Partners for $40 million—and immediately leased it back.

Mercer is one of a growing number of companies turning to sale-leaseback deals as a means of raising capital in a booming market for commercial and industrial space, real-estate executives and advisers said. Companies are finding willing buyers in real estate-focused funds, flush with cash and armed with…