Roger Federer survived a stern examination from a resurgent Marin Cilic to triumph 6-3 4-6 6-4 6-2 and reach the fourth round of the US Open.

It was a tough draw for Federer against a player who was a semi-finalist at the Australian Open last year and ranked in the top 10 before a slump in form.

Cilic was only the 27th seed for the tournament but he breezed through his first two matches against young guns Ryan Harrison and Bernard Tomic and looked back to something like his best.

He carried on that form in this match and created two break points in the third game, but Federer saved them and then rubbed salt in the wound with a break of his own, which he held to win the opening set.

The match was of a very high quality, with Cilic using his power to take control of plenty of rallies, while Federer countered that with his armoury of skills and some impressive serving.

The second set was tight all the way until the Croatian blasted his way to two set points with Federer serving at 4-5, and took the second.

It was a dangerous moment for the 16-time grand slam champion but he responded with an immediate break at the start of the third only for Cilic to respond in kind.

The key moment of the match came in the ninth game, with the 22-year-old under pressure on his serve.

Facing break point, Cilic was warned for taking too long between points and promptly sent down the most untimely of double faults.

Some big serving secured the set for Federer and he was on his way when he broke again in the third game of the fourth set.

There was no way back for Cilic as his opponent reeled off three games in a row to clinch victory after two hours and 40 minutes.

Ninth seed Tomas Berdych became the 17th singles player to pull out of this year's US Open during his match against Janko Tipsarevic.

The Czech had been struggling with a right shoulder problem since the Masters 1000 event in Cincinnati two weeks ago and, although he survived matches against Romain Jouan and Fabio Fognini, this proved a step too far.

Tipsarevic, the 20th seed, had taken the first set 6-4 when Berdych took a medical time-out to receive treatment. He carried on but lost the next five games before opting to call it a day.

Serb Tipsarevic, who has now beaten Berdych in all their four meetings, will play in the fourth round of a grand slam for the first time since Wimbledon in 2008.

No sooner had Berdych retired than 31st seed Marcel Granollers also quit, succumbing to what appeared to be a back problem while trailing fellow Spaniard Juan Carlos Ferrero 6-1 4-3.

The high number of withdrawals have been a major talking point of the tournament, with two players pulling out before the start, two more choosing not to play their matches - including Venus Williams - and 14 more retiring mid-match.

Former world number one Ferrero, 31, has been battling back from knee and wrist surgery and he will meet Tipsarevic for a place in the quarter-finals.