The fifth-seeded Ivanovic won her first-round match in the Bank of the West Classic, defeating Sabine Lisicki 7-6 (2), 6-1 on Tuesday. The former world No. 1 lost to Lisicki in three sets in their previous meeting at Wimbledon.
''My mentality has changed,'' Ivanovic said. ''Sometimes just a few points make a difference and it helps to be positive in a tight situation. I did that today in the tiebreak.''
She also hired Dejan Petrovic and was playing her first tournament with him.
''It was a lot of things on and off the court,'' Ivanovic said of her split with Nemanja Kontic following the loss to Lisicki at Wimbledon. ''He helped me a lot and sometimes these decisions are very hard.''
Williams, also a former No. 1, beat qualifier Paula Kania, 6-3, 6-2. She'll next play fourth seeded Victoria Azarenka, whom she has beaten in three previous meetings.
''She's always a tough competitor,'' Williams said. ''I'll need to be focused and on my toes.''
Ivanovic has won three tournament titles on the WTA Tour this season after failing to win a tournament in 2013. She owns 14 career titles.
''I don't think like that,'' she said. ''When I was being introduced, I heard that I won three titles and I thought `I did?' I knew I had played a lot of matches, so maybe I should not have been surprised.''
Ivanovic fell behind in the first set and rallied to win it in a tiebreaker.
''It was a tough first match for both of us,'' Ivanovic said. ''She was playing very well. In the tiebreak I thought I had to be aggressive, so I came to the net. I felt confident in doing that.''
The Serbian next faces qualifier Carol Zhao, a sophomore at Stanford who was leading Yanina Wickmayer, 6-2, 1-0, when the Belgian retired because of a viral infection.
Williams, who made her pro debut in the event 20 years ago, has won two titles and reached the finals five times in 12 previous appearances.
''This and Wimbledon are probably my two best results,'' Williams said. ''I still think hard is my best surface just because I grew up on it. It's great to be feeling good enough to be playing.''
Ranked 25th and no longer the dominant figure on the tour, Williams thinks she still has a Slam title in her.
''That's why I still work through any issues,'' she said. ''When the chance comes, I'll have put in the work. I still want to get the best out of myself. If I get slow and terrible, I'll stop and fade into gray.''
In other matches, Garbine Muguruza downed defending tournament champion and sixth-seeded Dominika Cibulkova, 6-2, 4-6, 6-2, Monica Puig beat seventh-seeded Carla Suarez Navarro, 6-3, 7-5 and Daniela Hantuchova topped Paula Ormaechea, 6-3, 6-4.
''When I play someone higher in the rankings I don't feel pressure,'' said the 28th-ranked Muguruza. ''I just out and play. This is a really fast court and that's good for my game. The court helps me sometimes.''
She improved to 2-0 against the 12th-ranked Cibulkova.