Havlat backhanded the puck into an open net after Detroit's Justin Abdelkader had fallen on top of goalie Jimmy Howard during a scrum in the crease, giving the Sharks their seventh point over a four-game span.
Havlat also scored in the first period and Joe Pavelski added a goal for San Jose, which pulled into a tie with the Los Angeles Kings for the eighth and final playoff in the West with 82 points.
Antti Niemi made 26 saves to pick up the key victory.
Pavel Datsyuk scored in his return after an 11-game injury absence and Valtteri Filppula also scored for the Red Wings, who fell for the fourth straight game.
Howard finished with 32 saves for Detroit.