The median price of single-family homes in Massachusetts fell 12.3 percent in July, marking the sharpest decline in monthly home prices since The Warren Group, Banker & Tradesman’s parent company, began tracking the housing market in 1987.

The median price for single-family homes sold in July dropped to $320,000 from $365,000 in July 2007, according to The Warren Group. The year-to-date median price is $316,000, a 9.7 percent decline from $350,000 a year ago. Prices have decreased in every county this year except for Nantucket, where they have flattened.

“The good news in July was that home sales didn’t decline as precipitously as they have in the previous six months of the year. Unfortunately, prices dipped even more than they did this past April, when prices were 12 percent lower than a year earlier. The drop is a dramatic turnaround from five to six years ago when prices were escalating by double-digit percentages,” said Timothy Warren Jr., CEO of The Warren Group. “Foreclosure activity has certainly dragged down home prices and will continue to affect the overall market.”

Sales of single-family homes also continued to drop in July, slipping 6.4 percent to 4,495 from 4,800 in July 2007. It was the only month this year that monthly sales haven’t declined by double-digit percentages. Meanwhile, year-to-date sales are down 16.9 percent, to 22,976 from 27,651.