ATLANTA — The Mets looked like a group caught unprepared for a fire drill. They scratched and clawed and scrambled, and after a precarious 8-6 victory over the Braves on Friday night, most admitted they still didn’t know exactly how all of it happened.

Yet they hugged and shook hands at Turner Field after the replay on the scoreboard in centerfield confirmed that they had avoided a catastrophic meltdown.

“Magical,” catcher Travis d’Arnaud said. “Miraculous.”

Steven Matz cruised through four innings, then nearly squandered an 8-0 lead, chased after surrendering six runs in the fifth inning. Later, he downplayed lingering elbow tightness.

Yet the Mets prevailed, getting 2 2⁄3 shutout innings from Hansel Robles ahead of a four-out save for Jeurys Familia.

The final three outs came with a dose of drama.

advertisement | advertise on newsday

With two on and nobody out in the ninth, Chase d’Arnaud bunted a soft liner down the third-base line. Wilmer Flores dived, hoping to catch it on the fly. He later said he lost sight of the ball, which hit the ground. Still, the runners failed to move up.

Flores tagged third base, then fired to second for the force, extricating Familia from trouble.

“That was crazy,” Flores said, shaking his head at a mistake that worked out. “I was trying to catch the ball.”

The final out came on a strikeout in the dirt, which required a rushed throw by d’Arnaud and a sprawling effort by first baseman James Loney, who picked a one-hop throw although the ball was partially shielded by Jace Peterson as he raced up the line.

“I had to anticipate what side he’d throw it on and then I went to that side,” Loney said. “I knew it’s going to be over there somewhere.”

Mets videos

The replay showed that Loney somehow caught the tough one-hopper while dragging his foot across the bag.

With that, the Mets pulled to within three games of the front running Nationals and Familia established a franchise record, saving his first 25 chances to begin the season. He passed the mark of 24 by Armando Benitez in 2001.

Of course, it was remarkable that Familia’s services were needed in the first place.

Matz cruised through the first four innings, surrendering one hit, but he lost his command in the fifth. Before his implosion, television cameras spotted him in the dugout rubbing his left elbow, the same one that tightened up in his last outing.

However, after the game, manager Terry Collins said Matz made no mention of an elbow issue.

advertisement | advertise on newsday

“It’s been tight but it’s fine,” Matz said. “I was able to throw the ball fine the first four innings and it just got away from me.”

Matz equaled a season high by allowing nine hits. For the first time in his career, he did not record a strikeout.

Adonis Garcia had a two-run double, Brandon Snyder hit a three-run homer and Freddie Freeman had an RBI single in the fifth.

Yoenis Cespedes, back in the lineup after hurting his left wrist, endured an eventful night. He lost a ball in the sky, which contributed to Matz’s disastrous inning. He also twisted his left ankle while getting picked off at first base. Later, he downplayed the issue.

Despite the scares, the Mets beat the last-place Braves for the first time in five tries.

advertisement | advertise on newsday

Loney hit a three-run homer to go along with his save at first base. D’Arnaud knocked in three runs and Flores ripped an RBI double.

For the second time this week, Robles (2-3) delivered a timely multiple-inning outing. He recorded the final two outs in the fifth — bailing out Matz — then stayed for two more shutout frames. He finished with 2 2⁄3 scoreless innings in his first outing since allowing one run in a career-high 3 2⁄3 innings in relief of the injured Bartolo Colon on Tuesday.