The Briton, second behind Stefan Bradl on Friday, took pole midway though the second session and had extended his advantage to 0.541secs with seven minutes to go, before coming under late pressure from fellow Aprilia rider Terol.
A half second gap then separated Terol from third placed Mike di Meglio, with reigning world champion Gabor Talmacsi completing the front row.
Championship leader Simone Corsi failed to improve and slipped from fourth to eleventh as a result, while provisional pole sitter Bradl will line-up eighth after also losing ground.
Final qualifying - Shanghai:
1. Smith (Aprilia)
2. Terol (Aprilia) +0.028secs
3. di Meglio (Derbi) +0.541secs
4. Talmacsi (Aprilia) +0.648secs
5. Iannone (Aprilia) +0.783secs
6. Olive (Derbi) +0.785secs
7. Espargaro (Derbi) +0.809secs
8. Bradl (Aprilia) +0.820secs
9. Gadea (Aprilia) +0.898secs
10. Webb (Aprilia) +0.971secs
24. Redding (Aprilia) +2.728secs