Toll Bros. is a highly profitable luxury homebuilder. So how did its Horsham HQ end up in foreclosure?

Toll Bros., the Horsham-based luxury homebuilder, recently notched its fourth straight year of record profits, with net income topping $1 billion for the first time. Sales are approaching the company’s real-estate-bubble high of $6 billion (not counting inflation) back in 2006.

But it’s another story for Toll’s suburban three-story headquarters at 250 Gibraltar Rd.

The homebuilder’s headquarters went into foreclosure last year, and Toll is looking around for a possible new headquarters site.

How did the offices of a Fortune 500 company, known for high-windowed suburban homes and modern city units, end up in foreclosure with new, mystery owners?

The details aren’t unusual: A number of properties in Philadelphia’s central Montgomery County suburbs, and in other weak suburban markets such as Wilmington, are worth less than investors paid for them a decade ago, according to a recent report by Trepp, which tracks commercial properties and the debt investments guaranteed by those properties.

For these buildings in markets that haven’t yet returned to their mid-2000s peak valuations — and generally for aging buildings that can’t command top rents — owners and investors continue to default on financing for buildings bought years ago at inflated prerecession prices.

It may not be worth it to building owners to repay lenders at yesterday’s high prices, when they owe more than the buildings are worth. So banks and investors step in to try to resell the properties, foreclosing the debt or renegotiating terms. Sometimes debtors end up buying back their properties at a discount.

Toll’s  headquarters foreclosure isn’t really Toll’s problem: It sold the building soon after opening the office in 2004, and leased it back for about $13.50 a square foot a year, less than half of what prime space now rents for in top Center City and Main Line markets.

“Business continues as usual for us, as our lease runs for another 17 months, and we have unilateral rights to a series of five-year renewals,” vice president Christine Sciarrotta told me.

So the building’s financial challenges belong, not to tenant Toll, but to its owners and their creditors.

Indeed, since its headquarters was sold in foreclosure in April, Toll isn’t sure who the owners are, Sciarrotta added: “We are uncertain of the legal entity that owns the building post foreclosure.”

With its lease set to run out next year, Toll Bros., like a hard-to-pin-down home buyer, is looking at possible new locations. Or it could stay put: “We continue to explore various alternatives to buy and renovate, renew, relocate, or build to suit,” Sciarrotta concluded.

How did it come to this? The Florida investors that bought the building from Toll resold it in 2007, at the height of the real estate bubble, to a Delaware-registered investment company, Buckhead Gibraltar LLC, which paid mostly with a $35 million commercial real estate financing arranged by the former Wachovia Bank.

The buyer is a limited-liability company incorporated under Delaware law, which, as in many states, allows the actual owners to remain unidentified unless law enforcement investigators compel the company’s Delaware agents to give up their names. And nobody has announced any investigations or suspicion of wrongdoing in this case.

Toll’s lack of a longer-term commitment to 250 Gibraltar, and the lack of other long-term tenants, was a factor in the property’s valuation, according to reports Trepp cited.

On the 2007 deal, Wachovia accepted annual interest payments, and agreed to collect the principal by 2017. But by then the aging property was appraised at just $23 million, more than one-third below the remaining value of the debt, said Trepp analyst Sean Barrie.

So the owners failed to pay what they promised on time, and the building was foreclosed by creditors, who hired LNR Partners — a servicing company in Miami that caters to foreclosed properties — to manage the property while owners and creditors reorganize. LNR still manages the building, two months after its resale to new, mystery investors.

The lender that set up financing for the 2007 sale, Wachovia, is long gone: Dragged down by underwater mortgages and other deflated investments, the company was forced into a bargain-priced recession acquisition by Wells Fargo & Co. in 2010. Wells Fargo wrote off billions in bad loans and has sold much of its inventory at a discount to investors who try to collect the balances as loans come due.

Even in its depressed state, 250 Gibraltar generates $500,000 in annual real estate taxes to local governments, mostly to the Hatboro-Horsham School District.

The Toll building is one of the biggest foreclosed properties now under reorganization in the Philadelphia area.

Similarly sized examples facing reorganization and resale include Liberty Plaza in Northeast Philadelphia, which defaulted on $43 million in loans; 800 Delaware Ave., a Wilmington office building, also $43 million; the Sheraton Suites Hotel at 422 Delaware Ave. Wilmington, just down the street, where borrowers owe $34 million; and 500 Virginia Dr., a Fort Washington office building, $29 million, according to Trepp.