The top-seeded German recovered from letting two match points slip in the second-set tiebreak to secure a 6-4, 6-7 (8-10), 6-3 victory and record his 60th win of the season.
Zverev had to work hard to break Halys in the opening game, needing seven break-point opportunities before finally making the breakthrough. However, he did not face a single break point throughout the match.
The world number two appeared poised for a straight-sets victory before Halys saved two match points in the second-set tiebreak and levelled the contest with an overhead volley winner at the net.
Zverev responded by breaking the Frenchman's serve in the opening game of the deciding set, regaining control to complete the win and improve his head-to-head record against Halys to 4-0.
He will next face Alexander Bublik, who battled back from a set down to defeat Brandon Nakashima 6-7 (7-9), 6-3, 7-6 (7-5).
Shelton, meanwhile, could not find a way past Gea, with the 21-year-old Frenchman claiming a 7-6 (7-5), 7-6 (7-3) victory over the third seed.
The American had celebrated his 24th birthday by winning his opening match in Shanghai, but his campaign ended after two closely contested sets. Gea held his nerve in the second-set tiebreak, converting his first match point after Shelton faced three opportunities to stay in the contest.
Seventh seed Frances Tiafoe also suffered a narrow defeat, losing 7-6 (7-4), 4-6, 7-6 (8-6) to Alejandro Davidovich Fokina despite having a match point in the deciding-set tiebreak.
Ninth seed Alex de Minaur advanced with a 7-6 (8-6), 6-4 win over Rei Sakamoto, while 26th seed Karen Khachanov defeated Adrian Mannarino 6-2, 6-4.
Other players progressing included Jakub Mensik and Hubert Hurkacz, with the remaining third-round matches, including Carlos Alcaraz against Zizou Bergs, scheduled for Monday.