Vahaly, who beat world number one and French Open champion Juan Carlos Ferrero at Indian Wells in March, rallied well and took an early lead against the third-seeded Spaniard.
But Moya immediately broke back in the third game and Vahaly had to fight off three break points at 2-2.
With Moya looking flat, a careless volley offered Vahaly a break point to lead 5-3, but the Spaniard held off that threat with a smash.
The 24-year-old American held a set point at 5-4, but netted a return and Moya then broke to lead 6-5. A break for 1-0 on his fourth break point gave Moya a lead in the second set, and that was enough to settle the match.
In an all-Croatian battle, sixth seed Ivan Ljubicic defeated Mario Ancic 6-1 6-4, winning the last five games of the first set and breaking to lead 5-4 in the second after Ancic failed to convert four game points.
Results:
Second Round: Ivan Ljubicic (CRO) bt Mario Ancic (CRO) 6-1, 6-4; Gregory Carraz (FRA) bt Alexander Popp (GER) 7-5, 6-2; Nicolas Thomann (FRA) bt Joanthan Erlich (ISR) 6-4, 6-0; Carlos Moya (SPA) bt Brian Vahaly (USA) 7-5, 6-4; Jarkko Nienimen (FIN) bt Bohdan Ulihrach (CZE) 6-4, 6-2; Taylor Dent (USA) bt Thierry Ascione (FRA) 6-1, 6-2
Shanghai ATP Results
Second Round: Guillermo Canas (ARG) bt Eric Taino (USA) 6-7 (1/7), 6-4, 7-6 (7/3); Scott Draper (AUS) bt Martin Verkerk (NED x2) 6-7 (4/7), 1-0 retired; Wayne Arthurs (AUS) bt Takao Suzuki (JPN) 6-2, 6-2; Robin Soderling (SWE) bt Justin Gimelstob (USA) 6-4, 6-4; Mark Philippoussis (AUS) bt Jeff Salzentstein (USA) 6-1, 7-5; Ivo Karlovic (CRO) bt Nicolas Kiefer (GER) 6-1, 7-6 (7-5).—Reuters