WASHINGTON — It had been nearly three weeks since the lights went out on the Mets’ offense, long enough to wonder when the power outage would end.

The answer came at freshly soaked Nationals Park, in a 7-1 pounding of the Nationals Monday night as the Mets blasted three homers and vanquished one of their most consistent tormentors.

Gio Gonzalez hadn’t lost to the Mets since September 2014. In his five subsequent starts against the Mets, he went 4-0 with an 0.97 ERA. But he was chased after allowing seven runs and 10 hits in only five innings.

David Wright, Yoenis Cespedes and Neil Walker hit home runs to propel the Mets (26-18) to their fourth consecutive victory. They shaved the Nationals’ lead in the NL East to a half game.

The Mets hadn’t scored seven or more runs in a game since an 8-0 triumph over the Braves on May 4 — the Mets’ final game before departing on an 11-game Western swing that turned their bats into wet newspapers.

Rain delayed the start of Monday night’s series opener by about an hour, though the Mets quickly showed that they were not bothered by the slop.

Wright hit a three-run homer to spark a five-run third inning. And in the fifth, Cespedes and Walker hit consecutive solo shots off Gonzalez.

Cespedes’ 15 homers lead all of major-league baseball. He has 32 home runs in 97 regular- season games since the Mets acquired him at the trade deadline last July.

Meanwhile, Bartolo Colon celebrated his 43rd birthday a few hours early, pulling himself out of a personal tailspin by holding the Nationals to one run in seven innings. He had allowed eight runs in 9 2⁄3 innings over his last two starts. In his previous outing — against these same Nationals — he issued an uncharacteristic five walks.

But Colon (4-3, 3.44 ERA) settled down after escaping early trouble. Ryan Zimmerman laced a two-out RBI single in the first off Colon, who allowed only two more baserunners to reach scoring position.

Now, the Mets can only hope for a similar bounce-back from Matt Harvey, who starts Tuesday night after his career-worst performance against the Nationals on Thursday nearly got him bounced from the rotation.

Indeed, the Mets needed some good news. Though they had come off a three-game sweep of the Brewers this past weekend, the sting of last week’s series loss to the Nationals at Citi Field had lingered.

The Mets were outscored 16-2 in the final two games of that three-game series against their NL East rivals. Since then, the line had gotten only thinner.

Before Monday night’s game, the Mets placed first baseman Lucas Duda on the disabled list. Now, for six weeks at least, the Mets will be without one of their most dangerous hitters. He will be replaced by a rotating cast of backups, though it’s possible that the Mets may be forced to explore a trade.

But for now, the Mets aren’t entertaining any drastic measures to replace Duda.

For one night, anyway, the Mets barely noticed his absence. The awakening came against an unlikely foe in Gonzalez (3-2, 2.87 ERA), who held the Mets to one run in 6 1⁄3 innings five days earlier.

Wright ensured it would be different this time. With two on in the third, Gonzalez left an 82-mph changeup over the heart of the plate. Wright pounced, ripping it to left for a three-run shot. Cespedes and Walker followed with hits ahead of Asdrubal Cabrera, whose run-scoring single gave the Mets a 4-1 lead. Eric Campbell added a sacrifice fly, just the Mets’ fourth of the season.

In the fifth, Gonzalez surrendered homers to Cespedes and Walker, the Mets’ seventh back-to-back homers of the season.