In a rare defeat for caveat emptor in foreclosure sales, a judge let a winning bidder cancel the $2.6 million purchase of a house because 142 foul-smelling dogs and cats — some living, many dead — were found on the premises.

Bergen County Superior Court Judge Peter Doyne ruled that Michael Acciardi of Saddle River, N.J., was relieved of his obligation to buy the house next door because of conditions he discovered five days after he won the bid at an Aug. 10 sheriff’s sale.