Serena Williams loses in three thrilling sets. Now, she moves closer to retirement.

NEW YORK – When Serena Williams first walked onto the court at the U.S. Open this week, the question was how the greatest player in modern tennis would handle the pressures of what she said could be her last Grand Slam tournament.

Over the course of four days and two prime-time matches, it looked like the 40-year-old would mount a magical, storybook run for a 24th major title.

But that dream ended Friday night in a heartbreaking three-set loss to Ajla Tomljanovic of Australia. To the end, the almost 24,000 fans who packed Arthur Ashe Stadium shouted encouragement and cheered her every point as she fought against an opponent who was 11 years younger.

“It’s been the most incredible ride and journey I’ve ever been on in my life,” Williams, wiping tears, said on court after the match.

The loss, 7-5, 6-7 (4), 6-1, likely spelled the end of a 27-year career that forever changed the world’s perception and understanding of women in sports. The highlight reels will show Williams went kicking and screaming, saving five match points, blasting away to the end, making every stroke count as the match passed the 3-hour mark.

On another night, in another season years ago, it might have been enough. But on this night, a few weeks before her 41st birthday, Williams could not maintain the rarefied level of play that has powered so many of her victories. She served for both sets and had four set points in the second, only to let Tomljanovic, who had never played on this court in the biggest stadium in the sport, climb out of a 5-3 hole in the first and second sets. She matched Williams’ power and edged her in steeliness and accuracy, and also faced down a crowd that was entirely in Williams’ favor.

“I just thought she would beat me,” Tomljanovic said. “She’s the greatest of all time, period.”

Williams’ loss came on the same court where she won her first major title in 1999 at the age of 17. The fans this week came to Ashe to say goodbye, but with each match it was clear that no one wanted to see Williams go, not from the tournament she has won six times and not from tennis. Just 24 hours earlier, Williams had lost a doubles match with her sister Venus Williams. And as play moved into a third set Friday, Serena Williams was noticeably tired.

Her play this week, though, could make people wonder if she was committed to quitting. Through three matches and eight sets of tennis over five days that few will soon forget, Williams proved that she could still be great on a tennis court. She has said, however, that she wants to have a second child and cannot do so while traveling the world and competing.

She could always choose to return to tennis. But in an essay published in Vogue magazine last month, Williams wrote that she was “evolving away from tennis” – effectively announcing that she planned to retire. And in speaking to reporters after matches at the Open, she has not altered the plan.

Williams had a golden opportunity to take the first set after breaking Tomljanovic for a 5-3 lead. But she failed to close it out, and coming up short appeared to rattle her. She committed a series of errors, hitting balls long and into the net as Tomljanovic pounced on her opportunity and finished off the set with a forehand cross-court winner on which Williams barely moved.

It was a stunning end to a set that during the first eight games saw Williams, the 23-time Grand Slam champion, repeatedly send the big-hitting Australian backpedaling on so many points, moving her across the baseline and riding the energy of the crowd to gain the early edge.

For the first half-hour, the match looked destined to follow the pattern of her first two, with Williams mostly getting better with each set. But two errors on one of her signature shots – her swinging forehand volley – and a serve that became unreliable and wobbly did her in. After 49 minutes, she was in a hole.

Few players, though, react to a deficit the way Williams does. When she is healthy and in form, Williams experiences losing a set almost as an insult, an attack on an aura of invincibility that she will stop at almost nothing to maintain.

And that is exactly what she did Friday night. Her grunts grew louder, her serves harder and more precise. She dove across the pavement for one volley, and stabbed and thumped others. She surged to a 4-0 lead, then stumbled briefly but regained her form in time to get to the brink of drawing even. She held four set points at 5-2, and served for the set once more at 5-3, but could not make the shots she needed to when she needed them most. Somehow, though, Williams came alive in the tiebreaker, pushing into the court and layering her shots so close to the lines and clinching it with a stiff backhand return of Tomljanovic’s serve that the Australian could not get back.

Onto the third set they went. Once more Williams took an early lead, breaking Tomljanovic’s serve in the first game but then frittering away her advantage as her 40-year-old gas tank edged toward empty.

Tomljanovic reeled off six straight games. In the last one, Williams ripped a ferocious forehand winner and unleashed a throat-busting scream, sending the stadium into a frenzy once more. And once more, Tomljanovic let the noise fall over her and set herself to the task at hand. It would take her six match points to induce that last error from Williams, a final stroke into the net. And then it was done.

Speaking to the crowd through tears, Williams said it had been a “fun ride.”

“It all started with my parents, and they deserve everything. I’m really grateful to them,” she said. “These are happy tears.”

She gave a nod to her sister: “I wouldn’t be Serena if there wasn’t Venus,” she said.

She has said she planned to focus on growing her family and working with her venture capital firm. But as she played three rounds of tennis that conjured so many moments of the Serena Williams of old, that even she had struggled before Friday night to say firmly that tennis was gone for good.

“I don’t think so, but you never know,” she said.