PARIS — After playing so infrequently, it’s as if Serena Williams is starting from scratch.

It looked that way for a bit more than a half-hour Thursday in the French Open’s second round as she dealt with muscle soreness, a lack of verve and a bunch of mistakes.

And then, suddenly, after unleashing one particularly powerful backhand return winner that she punctuated with a shout, Williams was back. Animated. Determined. Dominant.

Shaking off rust in her first Grand Slam tournament since giving birth nine months ago, Williams recalibrated her shots and erased a deficit of a set and a break to beat 17th-seeded Ashleigh Barty of Australia 3-6, 6-3, 6-4.

“I lost the first set, and I thought: ‘I’ve got to try harder. I’ve got to just try harder,’?” she told the crowd afterward. “And Serena came out.”

Williams had all sorts of trouble in the opening set, compiling 12 unforced errors. By the time the second set was merely one game old, she had been broken twice in the match, each time at love.

But after her spark was lit, Williams started yelling and pumping her fist after pretty much every point that went her way. As big a hitter as Barty is, she is hardly in Williams’ class and never has been past the third round at a major.

Williams grabbed four consecutive games over a span of less than 15 minutes to lead 4-1 in the second set, which soon enough was hers. She gained control of the third almost immediately, breaking to go ahead 2-1, then pulling away.

After only three winners in the first set, she had 25 the rest of the way.

“When push came to shove, the real Serena came out,” Barty said. “And that’s one of her best assets. When her back is against the wall, the best comes out.”

Next for Williams is a third-round match against 11th-seeded Julia Goerges. Get through that and Williams would face five-time major champion Maria Sharapova, who beat Donna Vekic 7-5, 6-4, or 2016 U.S. Open runner-up Karolina Pliskova.