The number three seed fought back on two occasions, winning four straight games from 3-5 down in the first set and then recovering from a 2-6 deficit in the second set tie-break on the way to a 7-5 7-6 (9/7) victory.
Del Potro will face Borna Coric in the next round. He beat the Croatian 6-4 6-3 6-1 in the US Open fourth round last month.
Juan Martin del Potro of Argentina attends a press conference at the Shanghai Masters tennis tournament on October 10, 2018.
Fourth seed Alexander Zverev is also through after a 7-5 6-4 win over in-form Georgian Nikoloz Basilashvili. He will play Alex de Minaur in the last-16 after his 6-4 6-3 victory against Benoit Paire.
Wimbledon finalist Kevin Anderson cruised to victory against Mikhail Kukushkin, winning 6-3 6-2 in just 64 minutes and will play Stefanos Tsitsipas after the Greek saved three set points in the second-set tie-break en route to a 6-4 7-6 (10/8) win over Karen Khachanov.
Richard Gasquet of France reacts while playing against Juan Martin del Potro of Argentina during their men's singles second round match at the Shanghai Masters tennis tournament on October 10, 2018.
Image credit: Getty Images
Marco Cecchinato recovered from 1-4 down in a final-set tie-break to defeat Chung Hyeon 4-6 7-6 (7/5) 7-6 (7/5) in two hours and 35 minutes while British number one Kyle Edmund maintained his good recent form with a 6-3 6-4 win over Andreas Seppi to reach the third round in Shanghai for the first time.