WASHINGTON – His two linemates had already scored, so not one to be outdone, Alex Ovechkin completed the first-line hat trick. On a power play late in the second period, he snapped a puck in from his favorite spot on the ice to put the Washington Capitals ahead for good.

As the Capitals have climbed to the top of the league standings, their balanced scoring has been a strength, with offensive contributions coming throughout the lineup. But Washington’s stars still carry the biggest burden, and they came through Wednesday night against Boston. With goals from Ovechkin, T.J. Oshie and Nicklas Backstrom, the Capitals beat the Bruins, 5-3.

“They were dynamite,” Coach Barry Trotz said.

Playing his former team for the first time since joining Washington, Brett Connolly’s backhand in the third period gave the Capitals a two-goal cushion, and then with 4:07 remaining, Evgeny Kuznetsov scored for a second straight game to stifle any Boston rally.

With the game tied late in the second period, the Capitals got a power play when Boston defenseman Brandon Carlo was called for holding. Washington’s first man-advantage was a failure, the team struggling to get into its structure and sustain any zone time. It kept the puck in the offensive zone on its second chance.

Defenseman Matt Niskanen relayed the puck to Ovechkin in the left faceoff circle, and he shot it through a defender’s legs and then past goaltender Tuukka Rask with 15 seconds left before second intermission for a 3-2 lead.

In a loss to the Islanders on Tuesday night in New York, Trotz thought his top line of Ovechkin, Backstrom and Oshie lost its matchup against New York’s top line with center John Tavares. He met with the trio before giving it another head-to-had challenge in Boston’s elite trio of center Patrice Bergeron and wingers Brad Marchand and David Pastrnak. Washington’s top line quickly responded to Trotz’s mild criticism.

“I knew that they could be better,” Trotz said. “They should be a dynamite line every night. Tonight, they made a statement. I challenged them a little bit to up their game.”

Just 3:06 into the game, Oshie got behind the Bruins’ defense and Backstrom passed a puck between two players, threading it through two outstretched sticks. That sprung Oshie for a breakaway, and the known shootout specialist glanced behind his shoulder before beating Rask with a wrist shot.

“Once I looked back and saw that I didn’t have that much pressure, I slowed it down a little and it turned into a little bit of a shootout,” Oshie said.

Roughly 10 minutes later, that line scored again to lift the Capitals to a 2-0 lead 13:34 into the game. Rask saved Niskanen’s shot, but Backstrom snuck into the slot to slap in the rebound for his second point of the night. That gave Backstrom 19 points in his past 14 games.

“It’s really not a very complex formula that we have really,” Oshie said. “Nicky owes [Ovechkin], and I try to get in there and get pucks and score when I get the chance. It’s really pretty simple and when one of us isn’t going and isn’t supporting the other guy, everything else kind of breaks down. Tonight, we were good.”

An interference penalty by Connolly gave the Bruins a power play for the final two minutes of the period, and Marchand put a puck in the top corner of the netting. That marked the sixth straight game that Washington’s penalty kill, ranked fourth in the league entering Wednesday night’s game, had allowed a man-advantage score.

The penalty kill stumbled again in the second period, as Kuznetsov was whistled for tripping in the offensive zone and Marchand’s second goal of the game tied it. Washington’s shorthanded unit had been a strength for the team, as the Capitals allowed just four power-play goals in 44 times shorthanded for all of December. But it’s been leaky lately.

In the end, it didn’t prove too costly for the Capitals, riding their top skill players on Wednesday night.

“That’s going to be important for us,” Trotz said. “If we can go head-to-head with our best against the other team’s best every night and feel like we’re getting an advantage, then I know some of our other lines can take advantage in the same way.”