Williams upset 48th-ranked Camile Giorgi 7-6 (7-5), 4-6, 7-6 (8-6) after more than three hours at the Birmingham Classic on Monday for her first victory over a player in the top 50 in nearly four years.
Williams, a seven-time Grand Slam champion and five-time winner of the Wimbledon singles, was out for six months because of a hamstring injury sustained in Auckland in the first week of the year.
On her return last week, she lost to 17-year-old Celine Naef in the first round at s'Hertogenbosch.
"There were so many moments where I thought, 'This match is over,' then she would hit a shot from out of nowhere," Williams said. "She pushed me to be better than what I thought I could be, and it's great for me.
"I haven't played a lot of matches, and it's great to come through."
There were also wins for third-seeded Pole Magda Linette, fifth-seeded Anhelina Kalinina of Ukraine and Bernarda Pera of the United States in the Wimbledon warm-up event.
In Italy the 2020 Australian Open champion Sofia Kenin defeated Tamara Zidansek 6-4 6-2 in the first round of the Veneto Open.
Ranked No. 127 after an injury-plagued 2022, Kenin raced to a 5-0 advantage in the first set then lost four straight games before closing it out and running away with the second.
It is the second year of the Veneto Open, the first WTA tournament played on natural grass in Italy.