SAN DIEGO — With one magical swing on Saturday, Bartolo Colon tested the bounds of human comprehension and confirmed, at long last, the existence of a baseball God.

Colon, the portly part-time cult hero, hit the first homer of his 19-year big-league career before earning the win in the Mets’ 6-3 victory over the Padres.

Before ending one of the most entertaining homerless streaks in baseball history, the veteran pitcher Colon stepped to the plate for the 247th time, a lifetime .089 hitter with just two extra-base hits on his resume.

But three pitches later, Padres righthander James Shields became a footnote to history, lowering his head as Colon rounded the bases on a two-run shot in the second.

It was one of four homers smashed by the Mets, who won after dropping the first two games of their 11-game West Coast road trip. Yoenis Cespedes lashed a two-run shot. David Wright and Michael Conforto went back to back with solo shots in the ninth for some added cushion.

But the biggest belonged to Colon, who then held the Padres to three runs in 62⁄3 innings. He left with a one-run lead, for which he had himself to thank.

Colon became the oldest player to hit his first career home run, besting pitcher Randy Johnson who managed the feat at age 40.

“This is one of the great moments in the history of baseball!” Gary Cohen boomed on the team’s TV broadcast. “Bartolo Colon has gone deep!”

Until Saturday, most of Colon’s plate appearances had resulted in hijinks, with only the occasional hint of competence. His at-bats were seemingly made for the animated GIFs that fill the Internet, his helmet-dislodging pretzel-twist of a baseball swing perfect fodder for the medium of millennials.

Sure, he’s flashed power in batting practice. This spring, he triggered a Twitter sensation one quiet morning in camp when he took hitting coach Kevin Long over the leftfield fence during batting practice. It was no wall-scraper, but a towering drive that took out a distant tree branch.

Still, taking such a majestic swing during a game seemed beyond the limits of reality.

Then, on a cool, crisp night in San Diego, it happened. When Shields tossed a 90-mph, get-me-over meatball over the heart of the plate, Colon tightened his grip, coiled his body, and uncorked a quick swing.

The barrel of his bat met the ball, and for an instant, Colon appeared off balance and stunned. From the box, he tracked the flight of the ball, near a “hit it here” target just beyond the fence in leftfield.

The ball carried, and carried, and carried. As Colon approached first base — the bat still in his hands — history disappeared over the fence. It was no cheapie.

According to Statcast, the ball came off Colon’s bat at 97 mph and traveled 365 feet.

Colon cracked a smile. In the Mets dugout, his teammates jumped up and down, moved by their sheer disbelief. They weren’t alone.

Within moments, the players retreated to the tunnel leading to the clubhouse. Just as they would to any rookie after his first homer, they intended to give Colon the silent treatment. But it would be awhile.

If the Kentucky Derby is the most exciting two minutes in sports, the most exciting two hours might be a Colon home run trot. He made Kirk Gibson on a bad leg look like Usain Bolt in the 100 meters. Statcast measured Colon’s journey at 30.6 seconds, though it seemed far longer.

Colon touched the plate then returned to an empty dugout, which was soon flooded by teammates. Wilmer Flores and Asdrubal Cabrera got to him first, triggering a mob.

Only three Mets have homered at age 42 or older: Willie Mays, Julio Franco, and now, the incomparable Bartolo Colon.