Home sales in California surged more than 12% in July from a year ago -- the biggest jump in sales in four years, a research firm said Tuesday.

A total of 39,507 new and pre-owned homes were sold statewide last month. That's up 12.3% from July 2007 and up 12.2% from June's total, MDA DataQuick said in a report.

Foreclosed homes accounted for 44.8% of all the homes sold last month.

The surge in foreclosure sales and home depreciation, coupled with fewer sales of high-end homes, helped drive down the statewide median home price to $318,000, a decline of 33.5% from July 2007.

The statewide median home price peaked in May 2007 at $484,000.

In the San Francisco Bay Area, prices plunged 29.3% in July to a 53-month low.

The median price for new and resale homes and condos stood at $470,000 last month, down from $665,000 in July 2007. The figure also marks a decline from $485,000 in June.