Jacob deGrom did his job Sunday, as did the Mets offense. But the defense betrayed the Amazin’s with a huge error that cost them three runs and likely a sweep of the Nationals.

With two outs and the bases loaded in the first inning, first baseman Pete Alonso made a nice diving stop to his right on a hard shot by Asdrubal Cabrera. It looked to be an inning-ending stop, but Alonso threw the ball wide of a covering deGrom, an error which plated all three runs in what became a 7-4 Mets loss to the Nationals.

“I just need to hit him in the chest; it’s as simple as that,” Alonso said. “I didn’t hit him in the chest, threw the ball over the bag but he wasn’t quite there yet because [Cabrera] hit a pretty hard shot to my right and diving on my knees I’m just trying to just get rid of it.

“But I didn’t hit him in the chest; it’s as simple as that. If I make that play, we’re probably still playing baseball right now. It’s a really tough pill to swallow. And yeah, I’ll just hit whoever’s on the mound in the chest next time. It sucks, but I’ll get him next time.”

Alonso’s toss should’ve hit deGrom in the chest and ended the threat, except the pitcher appeared to hesitate short of the bag. The ball glanced off his glove and rolled all the way to the on-deck circle. That scored Trea Turner and Anthony Rendon.

Eventually deGrom retrieved the ball and threw home, albeit on a hop, only to have catcher Wilson Ramos drop the throw to allow Juan Soto to score.

“Yeah, I think Jake thought he — and he even made the statement, ‘I should’ve had that,’ ” said manager Mickey Callaway.

“It’s nobody’s fault. But there’s a lot of years of experience in that dugout and not one of us have ever seen a ball not leave the infield with the bases loaded and all three runs score. So that was kind of tough, something that never happens happened on that play. We’ve just got to make the play next time.”

The Keystone Cops play left the Mets down 3-0, before deGrom slammed the door shut. He threw five innings and didn’t allow another run, allowing just four hits, striking out seven and walking just one. He lowered his ERA to 1.97 in his last 15 starts.

“I tried to make a good play to get Jake out of a jam there,” Alonso said, “but I need to make a better throw. It’s as simple as that.”

DeGrom wasn’t available for comment, having left early to catch a commercial flight to Florida to spend the off day with his family before rejoining the team in Atlanta.