Roger Federer was on his way out of the U.S. Open Thursday night for a sixth straight year. Then he wasn't.

Down two sets to Gael Monfils to start their quarterfinal match, down two match points to Monfils in the fourth set, Federer fought back for a 4-6, 3-6, 6-4, 7-5, 6-2 victory that sends him into the semifinals against Marin Cilic.

Federer won five straight U.S. Opens from 2004 to 2008 on the way to becoming the Fed Express. They were a big part of his portfolio of 17 Grand Slam titles, the most ever in men's tennis. Monfils, however, seemed as if he would express Federer right out of this tournament.

But Federer got a toehold in the third set, breaking Monfils in the first game, and after being broken in the fourth game, he broke back immediately and went on to win the set.

He got an early break on Monfils in the fourth set, but Monfils broke back. Serving at 4-5, Federer hit two forehands wide that gave Monfils the two match points. But Federer won four straight points to hold and then broke Monfils in the next game, again going on to take the set.

He motored through the fifth set and scratched and clawed his way into the semifinals.

The Arthur Ashe Stadium crowd was on his side.

"It was unbelievable, it was incredible," Federer said of the crowd's support. "It was awesome for both guys. Gael plays such great tennis and I think that helped get them into it."

Federer didn't get down on himself when he fell behind. "I still thought the finish line was a long way out for Gael," he said. "I was playing well. I served well, stayed in the match and felt great in the fifth."

Maybe this is a very good omen for Federer, especially with Rafael Nadal out of the tournament with an injury. The last time Federer came back from two sets down in a Grand Slam was at Wimbledon in 2012 against Julien Benneteau. That was the last Slam Federer won.

In the other quarterfinal on Thursday, Cilic defeated Tomas Berdych, 6-2, 6-4, 7-6 (4). It is only the second time that Cilic has reached a Grand Slam semifinal since his first appearance in a major in 2007.

Last year Cilic had to sit out the U.S. Open when he was handed a suspension right after Wimbledon; he failed a drug test for using a banned substance that increased his glucose. It was a nine-month ban that eventually was reduced to four months because the substance had been given to him by a member of his entourage.

While his suspension was unsettling, it wasn't altogether unproductive.

"Definitely, I mean, it was a difficult period," Cilic said after his slightly surprising win over the sixth-seeded Berdych. "I didn't know when I was going to start back. But it was also a good period for me. I matured a bit more and I was working day after day. I wasn't, you know, relaxing and doing nothing. So I think that helped me to improve physically. Also, it helped me to have enough time to put some new parts in my game, which are helping me to play this good now."