With 4 minutes remaining and the score tied 2-2, the Leafs' Tyler Bozak forced a turnover in the Lightning's zone.
Phil Kessel corralled the puck and sent it to the right circle, where Van Riemsdyk fired a wrist shot past Ben Bishop.
Bernier made 13 of his stops in the final period, including a scintillating glove save on Martin St. Louis with 3:17 left.
Nazem Kadri scored twice for Toronto, which halted a two-game skid.
Mark Barberio and Matt Carle scored for the Bolts.
Bishop finished with 23 saves.
Boston schools pull out free condoms over wrapping complaints
Millions of Getty images now available for free via embed tool