Bruins center Patrice Bergeron tossed a long pass to Marchand at center ice while on the penalty kill in the second period.
Marchand grabbed the puck and skated left before using a swift deke in the opposite direction to get around Karlsson. The Bruins forward fought through contact from Karlsson's stick and threw a quick back-handed shot to beat Sharks goalie Martin Jones through the five-hole.
Marchand's score tied the Bruins' record for most short-handed goals in franchise history. It was his 25th goal while being on the penalty kill, tying the mark set by Rick Middleton.
Boston defeated the Sharks 4-1 at the TD Garden. David Krejci, Charlie McAvoy and Jake DeBrusk each added goals in the Bruins' victory.
Marchand has 74 points (25 goals, 49 assists) in 62 games this season. It was his second short-handed goal of the year.
The Bruins are in second place in the Atlantic Division and Eastern Conference, trailing the Tampa Bay Lightning by 17 points. Boston is three points ahead of No. 3 seed Toronto.
The Bruins plays the Lightning on Thursday night in Boston.