There were few dull moments as Roger Federer took care of Nick Kyrgios in straight sets yesterday at the US Open and stayed on course for a potential quarterfinal matchup with Novak Djokovic, who also won in straight sets.

Federer, who fended off four break opportunities in a sluggish first set, eventually ran away with the match 6-4, 6-1, 7-5 to reach the fourth round for the 17th time in 18 attempts.

The world No. 2 hit 51 winners, none more specular than his running flick shot around the net post late in the third set that sent the fans into a frenzy. Even Kyrgios stopped to appreciate the moment.

“Yeah, it was unbelievable,” Kyrgios said afterward. “I’m probably going to place it on Instagram.”

Federer later explained that it was one of the more “unique” shots in his career.

“Like I explained on court, you don’t get an opportunity to hit around the net post very often because in practice, you, I mean, you can’t really train them,” he said. “The net is out further, and the court is more narrow, so for a shot like this to happen in a practice, you will be running into a fence, and you will hit it into the net.

“I have hit a few throughout my career, and sure, they are always fun. … As you’re hitting it, you’re like, ‘Oh, I can just shove it down the line and just flat.’ That’s what happened today.”

Today, Federer will take on Australian John Millman for a spot in the quarterfinals.

Djokovic was efficient in a 6-2, 6-3, 6-3 victory over No. 26 Richard Gasquet. He saved all five break points he faced and is now 13-1 for his career against Gasquet, including 11 wins in a row.

Djokovic has won two of his 13 Grand Slam titles at Flushing Meadows. He’ll face 68th-ranked Joao Sousa of Portugal in the fourth round Monday. Win that, and a meeting with Federer could be next.

“Look, I know that I’m the clear favorite in the match,’’ Djokovic said. “At the same time I will try to maintain the level of focus and performance and level of tennis that I’ve had today.’’

Also Saturday, two seeded men lost in the afternoon to unseeded opponents: No. 4 Alexander Zverev and No. 17 Lucas Pouille. Zverev has never made the fourth round in visits to New York after being beaten 6-7 (1), 6-4, 6-1, 6-3 by Philipp Kohlschreiber in an all-German matchup, while Joao Sousa defeated Pouille 7-6 (5), 4-6, 7-6 (4), 7-6 (5).