Playing in his fourth tournament of the year, and second hard-court event in preparation for the US Open later this month, Murray was edged out 6-1 1-6 6-4 in Cincinnati.
He has missed the last two editions of this tournament because of injury.
The 23-time grand slam victor hit 27 winners to steamroll the world No 23 Gavrilova and bounce back from the most lopsided loss of her career two weeks ago - 6-1, 6-0 to Johanna Konta in San Jose - to set up a meeting with Czech eighth seed Petra Kvitova in the second round. "In the first set he had a really good serve and big forehand but I was just trying to stay strong all the time and stay calm as well". 'I think I knew what I had to do. "If I can improve by 10, 15 percent, you turn a lot of those matches around". It's a good thing.
"You've got to keep it all in perspective, it's easier now for me to take time away".
After a first-round bye, Federer extended his Cincinnati winning streak to 11 matches since losing to Rafael Nadal in the 2013 quarterfinals.
Eighth seed Dominic Thiem was forced to withdraw without hitting a ball.
Nick Kyrgios served 39 aces, including one to save match point, to power into the second round with a dramatic 6-7 (2/7), 7-5, 7-6 (11/9) win over Denis Kudla.
The Australian will next face Croatian Borna Coric, who beat Daniil Medvedev 6-2, 6-3.
Williams also was knocked out in her last tournament at San Jose two weeks ago after reaching the Wimbledon final. "I started the year very well".
"I'm very happy, especially with the way I fought until the end", he said.
No 11 seed David Goffin advanced with a 7-5 6-3 win over Stefanos Tsitsipas, and Leonardo Mayer became the first player to reach the third round on the men's side with a 7-6 (7) 6-4 victory over 16th-seeded Lucas Pouille.
"Watching from afar is tough", said Federer, who will start against Peter Gojowczyk after the German beat Portugal's Joao Sousa 2-6, 6-4, 7-5. "I was so happy when I won the first set because I thought, 'Finally, one set for me'".
Elise Mertens scored a 6-4 6-2 first-round win over Magdalena Rybarikova.
For more sports coverage, visit the ABS-CBN Sports website.
- Motorola P30 renders leak, shows a very iPhone X-like design
- Bayer Has a Reason to Feel Monsanto Buyer’s Remorse
- Juventus Deal-Maker Could Consider Offer To Join Manchester United
- Wallabies captain Hooper cleared for Bledisloe opener
- Maurizio Sarri makes decision over Ruben Loftus-Cheek's future
- Ramos: "Real Madrid won't stop winning because Ronaldo left"
- Jimmy Fallon throws up during drinking game with Ryan Reynolds
- Entire parliament condemns Fraser Anning's controversial maiden speech
- Splits deepen over #Burqa comments by British ex-minister #BorisJohnson
- Wilfried Zaha remains committed to Crystal Palace