PHOENIX — Just before Matt Harvey surrendered a two-run homer to Jake Lamb on Wednesday afternoon, a fan in the stands at Chase Field yelled “Adriana!”

Following a 5-4 loss in 11 innings to the Diamondbacks, Harvey said he didn’t hear the reference to his former flame Adriana Lima. His focus instead had been trained on an outing that he called encouraging.

“It was a huge step forward for me,” said Harvey, who allowed three runs in 5 1/3 innings, allowing him to leave his start in position for the win.

It didn’t happen, with Robert Gsellman giving up the tying run in the seventh before Chris Hermann’s walk-off homer off Rafael Montero in the 11th. Still, Harvey ended a streak in which he had allowed at least five earned runs in three straight starts.

“If I could go back and change a couple of pitches, I would,” said Harvey, who struck out five but walked four as he battled command early. “But overall I felt much better today and probably the best I’ve felt in two years. It’s definitely positive.”

For the Mets to turn around their season, it must begin with starting pitching. Before the game, manager Terry Collins suggested that improvement from Harvey would be just as important as a win to end what had been a six-game losing streak.

Said Collins: “Today, for me, is a huge step for Matt to get out there and feel good about himself when he leaves the game, where hey, look, mechanically I’m sound again and we can move forward.”

advertisement | advertise on newsday

During the week, he reviewed video with pitching coach Dan Warthen. They seized upon a mechanical issue. Last year, Harvey said he felt tingling and numbness in his right index finger when he threw from his typical arm slot. It would later be confirmed to be the after effects of thoracic outlet syndrome, which required season-ending surgery.

Nevertheless, as Harvey attempted to pitch through the issue last season, his arm slot rose. Command suffered, as did the life on his pitches. The issue got only more complicated as he lost the feel of the baseball.

“A lot of bad habits from last year, when I couldn’t go through that angle,” Harvey said, summarizing his struggles in as a season in which he has a 5.56 ERA.

Immediately, the Diamondbacks established that they would punish mistakes. When Harvey threw a 96 mph fastball that leaked back over the plate, leadoff man Rey Fuentes pulled it down the rightfield line for a first-inning triple. He’d score one batter later on a Chris Owings groundout.

Harvey made the same mistake again to Paul Goldschmidt, missing with a 97 mph heater that lingered over the fat part of the plate. It went for a ground-rule double. Lamb, the next batter, fell behind in the count 0-and-2 only to work a walk.

Mets videos

It took 29 pitches for Harvey to get out of the first and he had been fortunate to surrender only one run.

In the second, Chris Hermann lashed a ringing double to lead off the inning. But Harvey escaped unscathed, even after giving up his third extra-base hit of the game, and then falling behind 3-and-0 to the opposing pitcher Patrick Corbin before finally putting him away.

Harvey allowed Lamb’s two-run homer in the third, but settled in. Even with runners on base, the righthander looked sharper, maintaining his velocity. Twice, he struck out Goldschmidt, no small feat.

Harvey even broke off a few vintage sliders.

“This is a process that may take a couple of times,” Collins said. “But he felt good about it and that meant a lot.”