Just as they looked like another game had slipped through their fingers — a two-goal lead was relinquished for the fifth time in the past eight games — the Washington Capitals found the mettle to fight back.

The Tampa Bay Lightning rallied from a two-goal deficit to tie the game with less than six minutes remaining in regulation, but a frenzied push resulted in a goal by Eric Fehr off a deflection in front with 51.5 seconds left to secure a 4-3 victory Thursday night, snapping the Capitals’ four-game losing streak.

It was just the third win in the past 10 games for Washington, which had scored three goals on nine shots in the first period to establish its initial lead. But the Lightning outshot the visitors, 24-11, in the final 40 minutes to gradually claw their way into the contest and require the late heroics.

“That’s the kind of stuff you can build momentum off of. Obviously it wasn’t pretty but we had a lot of energy on the bench after we scored,” said Fehr, who recorded a pair of goals. “We knew how big this win was for our team. I think that will help us build for [Friday when Washington hosts Toronto]. It’s going to be good for us to play a lot of games in a few nights. I think our team will take advantage of it.”

In many ways, this wasn’t the type of game the Capitals are accustomed to playing. They traded chances with speedy Tampa Bay and, despite numerous quality opportunities, couldn’t consistently put the puck on net. While they finished with only 20 shots on goal against Lightning netminder Anders Lindback (16 saves), the Capitals had another 37 shots either blocked or miss the target.

Meanwhile, Philipp Grubauer, making his 10th start in 14 games, faced yet another substantial workload but this one came with more odd-man rushes as Tampa Bay turned anything from a giveaway to a blocked shot into a catalyst for its transition game. Grubauer finished with 33 saves and made quite a few impressive stops in the third period — none better than a stunning split save on Ondrej Palat shorthanded — that prevented the Lightning from establishing momentum.