It was only a few years ago that the crash of the housing market had entire neighborhoods under siege. In Bakersfield, especially, it seemed every other block had an unoccupied house with an overgrown yard.

There were dire predictions of still more devastation as banks dumped their mounting inventory of foreclosed properties onto a market already burdened with a glut. The empty homes would deteriorate and draw crime. Home prices would plummet.

As one real estate ranking after another put Kern County in the top 10 nationally for the highest foreclosure rate, the region braced itself for Armageddon.

So how did we get where we are today, with available inventory scarce and bidding wars driving purchase offers above list price?

A combination of factors have come together to create this counter-intuitive situation, according to real estate experts.

Mostly, it's that banks and mortgage loan services are taking their time selling the homes they have amassed through foreclosure. Those properties -- owned by lenders but not yet for sale -- are what the industry calls "shadow inventory."

Estimates of the size of that inventory range from 4 million to 11 million homes nationwide, depending on whether you define it strictly in terms of foreclosures or include homes destined for foreclosure because owners are behind on payments.

The market would be in big trouble if banks put the entire shadow inventory up for sale at once, but so far neither they, nor consumers, are selling much.

Active listings of existing single-family homes for sale in the Bakersfield area totaled 1,410 last month, according to the Crabtree Report, a monthly gauge of the local housing market prepared by Affiliated Appraisers. That's down 47 percent from 2,662 in November 2010, when there were more Bakersfield-area homes for sale than at any other time since the housing market crashed in 2007.

In other words, there's not a whole lot for buyers to choose from.

"That's the conundrum a lot of markets are facing," said Daren Blomquist, vice president at Irvine-based real estate data firm RealtyTrac.

"The shadow inventory hasn't materialized yet despite two years now of downward trending in foreclosure activity."

Banks have competing interests to juggle.

On the one hand, they don't want to unload the homes too fast because that would drive down sale prices and wipe out the value of their remaining inventory, which already has been walloped.

Almost a third of the country's mortgaged housing stock is under water, according to Santa Ana-based real estate data firm CoreLogic. That is, borrowers owe more on their home than the property is worth.

In Bakersfield, the number of upside down loans is closer to half.

"Those are people who in a normal market would be selling their homes and upgrading, but if you're upside down you can't sell," Blomquist said.

But banks have good reasons to get rid of their foreclosures, too.

They're lenders, not landlords, and it costs money to maintain a house, particularly in cities that have become more aggressive about tracking down owners and fining them for health and safety violations.

There's also the matter of how toxic loans and securities backed by them affect the bank's balance sheet. Owning them has adverse tax and investment ramifications.

And for every home banks sit on, several new ones are coming in because the foreclosure crisis continues, albeit slower. The region still has some of the highest foreclosure rates in the country, but Kern County notices of default -- the first step in the foreclosure process -- have fallen 60 percent over the last four years.

All of that amounts to a glut in theory, but an entirely different environment in practice.

"It's a hard, hard market for buyers," said Barbara Apsit-Incardone, an agent with Coldwell Banker in Bakersfield.

Real estate professionals all over town have horror stories of would-be buyers forced into bidding wars that soar far above the initial asking price. The appraisal often comes in lower than the winning bid and lenders won't fund a loan for an amount that exceeds the appraised value, so buyers either have to make up the difference or walk away.

"A lot of people don't have that kind of money," Apsit-Incardone said. "They're already being asked for higher downpayments, and they need whatever cash they have left to put into improvements. You can't really ask the seller for too much in repairs because there's somebody standing in line behind you who is willing to put in new carpeting or paint."

Count yourself lucky if you even get that far, said Jack Doremus, a broker associate with RE/MAX Magic in Bakersfield. Local and out-of-town investors who don't need loans have an edge in the bidding, but even people with cash offers are losing in the mad scramble for limited supply.

"I had one investor I wrote 19 offers for and he couldn't get a single one of them accepted," Doremus said. "He just said the heck with it. It's very frustrating."

Buying a home in Bakersfield isn't impossible, he insisted. You just have to be dogged and move fast, because quality properties go quickly.

With the shadow inventory still looming, it's hard to know how long such conditions will persist, said California Association of Realtors Chief Economist Leslie Appleton-Young.

There is certainly going to be more demand as the economy improves, and record-low interest rates are becoming harder to resist for those in a position to sell who are sitting on the fence, she said.

But low education levels and double-digit unemployment in the Central Valley hold the region back, Appleton-Young added.

"We no longer talk about northern California and southern California," she said. "We talk about coastal areas versus inland."

The housing market in the Silicon Valley has withstood the real estate crisis better than most areas of the state because "it has a more highly skilled, highly educated labor force, and that's where the jobs are," Appleton-Young said.

Still, just about everyone agrees that even in stronger markets, there can't be a full recovery until the looming shadow inventory is liquidated.

Unfortunately, there's no government policy or change in market conditions that's going to trigger that immediately, Appleton Young said.

"There's no magic bullet," she said. "The simple answer is time."