Roger Federer hugs Maryland teenager Frances Tiafoe after their opening-round five-setter at the U.S. Open. (Geoff Burke/Usa Today Sports)

The teenager from Maryland without a title to his name ended up forcing a real, genuine smile of relief from Roger Federer just before midnight Tuesday at the U.S. Open.

Frances Tiafoe, born in Hyattsville and raised in College Park, was all bravado and verve. At just 19 years old and ranked No. 70 in the world, Tiafoe stretched the Swiss legend to five tense sets before Federer prevailed, 4-6, 6-2, 6-1, 1-6, 6-4, before a packed Arthur Ashe Stadium.

Federer awaits the winner of a match between Mikhail Youzhny of Russia or Blaz Kavcic of Slovenia, and either would be hard-pressed to capture the crowd the way Tiafoe did.

“It was more than a test, it was a good one,” Federer said. “I’m very happy with the match. It was exciting. It’s kind of why I came to New York, as well. To go through these emotions.”

Tiafoe warmed quickly to the role of underdog. His first serve was a force in the first set, and he won 68 percent of his points on it for the match. He caught the crowd early, and although Federer has long been a fan favorite at Flushing Meadows, the house stayed with Tiafoe throughout.

Federer, the No. 3 seed, has already won two Grand Slams in 2017 (the Australian Open and Wimbledon) to give him 19 overall. No man owns more. At 36, his record this year improves to a staggering 36-3.

Tiafoe, by contrast, owns a 2017 record of 7-26.

Yet the son of Sierra Leonean-Americans made those watching believe he could be the first teenager to defeat Federer since Rafael Nadal did it in 2005.

He capitalized early on subpar play from an off-kilter Federer, who said after the match he was struggling with his back, the same injury that kept him off court for the entire second half of the 2016 season. The 36-year-old looked his age for the first time all year compared to a bouncy Tiafoe.

Tiafoe wobbled early in the second set and Federer took advantage with a quick break.

When he finally won he hugged Tiafoe over the net, and gave him a sympathetic pat on the stomach.

“I think I had a bit of a slow start today, but Frances also felt good at the beginning,” Federer said.

Tiafoe, who reached a career-high No. 60 in July, put up a valiant effort and displayed his power and raw skill, if not tactical know-how. His Grand Slam inexperience showed, naturally — he made it to the second round of both the Australian Open and Wimbledon this year, and was knocked out in the first at Roland Garros.

But Tiafoe is one of the more enticing young players in the ATP for good reason. He was the youngest winner of the famed Orange Bowl juniors event at age 15. He notched one career benchmark already this summer in defeating red-hot Alexander Zverev, the winner of five ATP titles this year, at a Masters 1000 tournament in Cincinnati before the U.S. Open.

Tiafoe also knows how to work a crowd. He cheekily fist-bumped line judges all night when their calls went his way, and requested more noise from a rowdy crowd at Arthur Ashe Stadium — even when sound already filled the cavernous structure, over which the roof was closed because of heavy rain on Tuesday.

With the crowd in his corner, Tiafoe moved with ease and returned well even when Federer pinned him into corners, though he never truly relaxed against the champion. He did play up to the challenge, saving one match point in the final set and bringing the last game to deuce.

“Frances fought well, I must say,” Federer said on court after the match. “When things connect for him, he’s a great player, he’s going to have a great future ahead of himself.”

For Federer, hopes of another title stay alive as he navigates through a thorny top-half of the men’s draw. A potential semifinal meeting with Nadal, who won in straight sets early Tuesday, is still a possibility. As is his 20th Grand Slam trophy, even with an irksome back prone to test him in inopportune moments.

“I wasn’t here last year, I’m here this year, so I’m much, much better,” Federer said. “To get through a five-setter you have to be good enough, somehow.”