NEW YORK — An hour-and-a-half into his stay at the U.S. Open, Andy Murray had to wonder whether it would end quickly.

A week later, the same guy who hobbled through head-to-toe cramps in his first-round match looked strong on a day that was even more hot and humid — and now he’s in the quarterfinals. The eighth-seeded Murray beat No. 9-seeded Jo-Wilfried Tsonga 7-5, 7-5, 6-4 in 2 hours, 35 minutes on Monday.

“I don’t feel like I’m that far away from playing my best tennis,” Murray said.

He hasn’t reached a tournament final since back surgery late last year. Coming into the U.S. Open, Murray felt he was playing well but lamented that he was struggling to close out matches.

In a tight one against a tough opponent Monday, Murray won enough crucial points to pull out the victory in straight sets.

Tsonga had three break points to go up 3-0 in the third, but Murray fought them off to swing the momentum. He promptly broke in the next game to get the set back on serve, and then closed out the match with another break.

Murray, who still isn’t sure why the cramps struck so early in his opening match last Monday, drank too many fluids this time and gave himself a stomachache.

It was a tough draw for both players — and gets even tougher for Murray, who next faces No. 1 Novak Djokovic. That matchup feels much more like a Grand Slam title match than a quarterfinal, and for good reason. Murray and Djokovic have met five times in major tournaments, with four coming in the finals; the other was a semi.

Tsonga rolled into the U.S. Open full of confidence after beating Djokovic, Murray and Roger Federer in Toronto to win the title. In Tsonga’s 7-6 (5), 4-6, 6-4 victory over Murray in early August, he was the one winning the key points in a close match.

“Tennis, it’s never a straight line. It’s always like this,” Tsonga said, tracing peaks and valleys with his hand. “So today it was like this maybe at the wrong moment.”

Murray hasn’t been back to a final since becoming the first British man in 77 years to win Wimbledon in July 2013.

He beat Djokovic to clinch that title and also defeated him at the 2012 U.S. Open for the first Grand Slam championship by a British man in 76 years.

“Great memories from that match,” Murray said in an on-court interview. “Hope we can play another top-level match.”

Murray, he said, “knows how to play center court U.S. Open where he played some great tennis and we had some great matches.”

They went to five sets twice in 2012, in Djokovic’s win in the Australian Open semis and Murray’s breakthrough victory in the U.S. Open.

“Long games, long rallies, long points, because we do a lot of the same things well,” Murray said.

When Murray’s ranking slipped after the surgery, it left him vulnerable to this sort of draw: He could potentially play Tsonga, Djokovic, Australian Open champ Stan Wawrinka and 17-time major winner Roger Federer in the last four rounds. Wawrinka beat 16th-seeded Tommy Robredo 7-5, 4-6, 7-6 (7), 6-2 on Monday.

Murray may finally be playing well enough to make that run sound plausible.

“It’s still obviously a long way from trying to win the tournament,” he said, “but it’s only nine sets now, three matches. ... Maybe five, six days away from potentially winning another Grand Slam.”