This is what ran through Roger Federer's mind as he stood one point from losing to Gael Monfils in the U.S. Open quarter-finals: "You got the back against the wall and hope to get a bit lucky and you hope to play exactly the right shots that you need or that he completely just messes it up. Either way works, as long as you get out of it."

Federer got out of it. Twice.

Steady as ever, even at 33, Federer saved two match points en route to coming all the way back from a two-set deficit, edging the 20th-seeded Monfils, 4-6, 3-6, 6-4, 7-5, 6-2 on Thursday night to reach the semifinals at Flushing Meadows for the first time since 2011.

Frustrated by the Frenchman's unpredictable style, flummoxed by the swirling wind, and missing shots he normally makes, Federer was on the verge of defeat while trailing 5-4 in the fourth set.

The 17-time major champion's mind was racing.

"That is a very frustrating moment to be in," Federer said. "Being down match point, it's just not fun because you're so close to leaving the court, head hanging down and ... going to take a shower and going to have to do press and all that stuff, which is so annoying after you've lost." 

federer-roger-140904

Roger Federer of Switzerland hits a backhand return in a 4-6, 3-6, 6-4, 7-5, 6-2 victory over Gael Monfils on Thursday night. (Julian Finney/Getty Images)

"It's hard to block it out, [but] you snap right back in because you don't have that much time," he continued. "You're like, 'OK, let me try and hit a good serve. Let's hope it works, because I don't want to hit a second serve,' all that kind of stuff. 

"I have to face it and embrace it."

That he did.

With Federer serving at 15-40, Monfils had an opening for a backhand passing shot, but it flew long. At 30-40, Federer produced a forehand winner, and the crowd roared. Two points later, it was 5-all, and then Monfils double-faulted twice in a row to get broken.

Everything had changed, putting Federer on course to winning for the ninth time after dropping the opening two sets of a match.

"It came quick," said Monfils, who said he felt physically and mentally drained late.

"It's a matter of five minutes," he said. "I think I was down five minutes. Roger just [jumped] on me."

Afterward, Federer credited the raucous support he heard in Arthur Ashe Stadium, saying the spectators "definitely got me through the match."

"It grows your belief that you can hit better shots, you can dig out more tough balls, you can serve better," he said. "All that just helps solidify your belief.

"I must say tonight was actually quite emotional for me."

'I knew I could play better'

Monfils, 28, was trying to reach his second career Grand Slam semifinal. Instead, Federer advanced to his 36th, ninth at Flushing Meadows. Five of Federer's major titles came at the U.S. Open from 2004-08, but he exited in the quarter-finals in 2012, and the fourth round in 2013.

It took Monfils 78 minutes to build a two-set lead, shaking of a twisted right ankle that left him down on the court. It helped that Federer made 26 unforced errors in that span.

And as if all he had to do was want to improve his play, Federer did. He suddenly was remarkably cleaner, with only one unforced error in the third set, and two in the fifth.

Attacking the net helped: Over the final three sets, Federer earned the point on 34 of 46 trips forward.

"I knew I could play better after the first couple of sets," Federer said. "I believed I could turn it around from the get-go when the third set started."

Monfils is nothing, if not unpredictable. In an era where some men, including Federer, have two coaches, Monfils goes without any. He'll admit to tanking points, games or entire sets. He sips sodas during matches, including Thursday. He'll go for a between-the-legs shot when a mundane forehand would do.

Make no mistake, though. This was not easy. The turnaround might not have been possible for Federer a year ago, when he was dealing with a bad back and trying to figure out whether he should switch to a larger racquet head.

But now Federer, however old, is approaching his skills of old. He got to the finals at his previous four tournaments — including a loss to Djokovic in Wimbledon's title match in July — the first such run by a 30-something since Ivan Lendl in 1990. One more victory, and Federer's final streak will stretch to five in a row.

Cilic bounces Berdych

cilic-marin-140904

Marin Cilic whoops it up over a 6-2, 6-4, 7-6 win over Tomas Berdych in the U.S. Open at Flushing Meadows, N.Y., on Thursday. (Al Bello/Getty Images)

Marin Cilic was not allowed to play last year in the U.S. Open, forced to the sideline by a four-month doping suspension that he says he did not deserve.

Home in Croatia, he set about improving his game and his fitness, eager to be a better player when he returned to the tennis tour. Now, he figures, that time off from competition is paying off on the court.

The 14th-seeded Cilic reached the second Grand Slam semifinal of his career - and first since 2010 - by beating sixth-seeded Tomas Berdych of the Czech Republic 6-2, 6-4, 7-6 (4) Thursday at Flushing Meadows, N.Y.

"I mean, it was a difficult period," said Cilic, thinking back to 12 months ago. 

"I didn't know when I'm going to start back. But was alsogood period for me.

"I matured a bit more and I was working, day after day. I wasn't 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."

Cilic, a former Top 10 player, tested positive for a stimulant after a match in Germany in May 2013, and the International Tennis Federation sought a two-year ban. He said he ingested the substance unintentionally via a glucose tablet bought at a pharmacy.

He initially was suspended for nine months, but the Court of Arbitration for Sport reduced that to four months on appeal last October, saying, "the sanction imposed was too severe." The court also restored ranking points and prize money that had been taken from Cilic.

"It angered me how all the process went because it was not fair to me," he said. "It wouldn't be fair to any tennis player.

"So that was just very bad memories. But, you know, when you're against big organizations, you are [a] small hand.

"You can't do much. So I just accepted it ... I erased it from my memory."

'Horrible from the beginning'

In his first major semifinal since the Australian Open four years ago, Cilic will face 17-time major champion Roger Federer, a 4-6, 3-6, 6-4, 7-5, 6-2 winner over Gael Monfils. 

Even so, Cilic thinks he's playing better than ever.

It sure looked that way against Berdych, the 2010 Wimbledon runner-up.

Both men are gifted servers, but that stroke failed Berdych on a wind-swept afternoon. Broken a total of four times through his first four matches, he lost four of his first five service games against Cilic, the first man from Croatia in the U.S. Open semifinals since his coach, Goran Ivanisevic, in 1996.

"Really, my serve was off," Berdych lamented. "Horrible from the beginning."

Through those initial five service games, he hit five double-faults and won only 8 of 25 points.

"Was very tricky with the conditions," Cilic said. "Very gusty.

"Not easy to deal with the wind and with ... the ball moving in the air. I felt that I was using the wind a bit better today."

'Absolutely no explanation'

Berdych seemed to making things a little more interesting in the third set, going up a break. But serving at 4-2, 30-15, he wound up in a protracted argument with chair umpire Louise Azemar Engzell over whether a ball had bounced twice before a lunging Berdych was able to put his racket on it.

"Have you ever had a racquet in your hand?" he asked her. "This is a horrible call.

"This is absolutely horrible call. There is absolutely no explanation."

That's not the sort of ruling that's subject to replay review in tennis, although a slow-motion shot showed that ball did, in fact, bounce a fraction of a second before Berdych got to it. He lost the next two points, too, to get broken, and Cilic was back in control.

And, of course, he's thrilled to be back on the circuit — and back in the latter stages of a major tournament.

He still harbours disappointment over the way his drug case was handled and says he never got a full explanation.

But Cilic also feels as though he's embarked on a second career, in a way.

"I felt that sort of my game just transformed," he said of his time away. "And I was able to, when I came back, start from zero."