The state of Massachusetts faced a deep foreclosure crisis several years ago as an expanding price bubble popped, leaving homeowners underwater and sending many into foreclosure.

Fast-forward a few years, and the Bay State is now experiencing a foreclosure petition rate that is well below year ago levels.

The state saw 248 foreclosure petitions filed in May, a dramatic 86% decline from 1,779 foreclosures a year earlier, according to data from real estate research firm The Warren Group.

So what’s behind the steep drop?

Timothy Warren, CEO of the Warren Group, says for starters, the foreclosure crisis may very well be behind us. But Massachusetts homeowners also were given more time when legislation passed in 2012 forcing lenders to consider foreclosure alternatives before launching a full-fledged foreclosure.

Changes in state law – many of them large-scale – caused a shift in the Massachusetts market, delaying foreclosure timelines and forcing servicers and lenders to seek out other avenues, the data suggests.

Foreclosure deeds, a reflection of completed foreclosures, fell more than 68% to 251 in May, down from 796 in May 2012.  

Foreclosure auctions also fell to 447 in May, a 69% drop from 1,446 last year.