Sharapova, who downed second-ranked Simona Halep in her first Grand Slam match after a 15-month doping ban, defeated Hungary's 59th-ranked Timea Babos 6-7 (4/7), 6-4, 6-1 at Arthur Ashe Stadium.
"It wasn't my best tennis," Sharapova said. "It was scrappy tennis but sometimes those kinds of matches are a lot of fun and this was one of those days."
The 30-year-old Russian, who next faces Russian-born US teen Sofia Kenin, tested positive for meldonium at the 2016 Australian Open, her most recent Grand Slam appearance until this week.
"Every day I have the chance I have to play at the US Open is a special day and I'll look forward to the next one," 146th-ranked Sharapova said.
Sharapova, whose five Grand Slam titles include the 2006 US Open, played only one Open tune-up match after a forearm injury but wore down Halep and Babos to prove she's a threat for a deep run, with Latvian 16th seed Anastasija Sevastova her top-ranked potential semi-final obstacle.
Fourth seed Zverev, whose five ATP titles this year include a win over Roger Federer in this month's Montreal final, fell to 61st-ranked Croatian Borna Coric 3-6, 7-5, 7-6 (7/1), 7-6 (7/4).
The 20-year-old German had been the highest-ranked player in his half of an injury-hit Open draw.
"It's upsetting because the draw is pretty open in the bottom part," Zverev said. "I felt like I should have been the favorite there. I just played a very, very bad match, so it's unfortunate."
Coric, who faces South African Kevin Anderson for a last-16 berth, was one point from a fifth set before winning five in a row to force the deciding tie-breaker.
"I was just thinking to keep the points shorter," Coric said. "And yeah, I was a little bit lucky."
Zverev's ouster left US 10th seed John Isner the top-ranked player in his draw quarter and Croatian fifth seed Marin Cilic the best in his half of the draw.
Wimbledon runner-up Cilic, the 2014 US Open winner, reached the third round by beating Germany's Florian Mayer 6-3, 6-3, 6-3.
Kyrgios, the 14th seed and former top-rated obstacle in Federer's quarter-final path, hurt his right shoulder in a 6-3, 1-6, 6-4, 6-1 first-round loss to 235th-ranked fellow Aussie John Millman.
"Early in the third set I hit one serve and I never felt the same after that," Kyrgios said. "Something didn't feel right in my arm."
Kyrgios, 22, dropped eight of the last nine games.
"Nick's shoulder deteriorated as the match went on," Millman said after his first US Open triumph. "It's a victory but slightly hollow."
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ