Lithuanian Aidis Kruopis finished third just ahead of Australian Mark Renshaw.
It was Cavendish's first success since winning the world road race title last September.
"It's obviously an extraordinary feeling," said the Isle of Man rider.
"I'm very happy. I was feverish two days ago, so I'm not 100%. And despite that I managed to beat a very impressive Boonen."
Boonen, who rides for the Omega Pharma-Quick Step team, holds the overall race lead after the 146km stage between Dukhan and the Al Gharafa Stadium here.
Wednesday's fourth stage will cover 144km from Al Thakira to Madinat Al Shamal in the north of the gas-rich Gulf state.
Results from the third stage of the Tour of Qatar on Tuesday over 144km between Dukhan and the Al Gharafa Stadium:
Third stage
1. Mark Cavendish (GBR) SKY 3hr 23min 48sec (average: 43.131 km/h), 2. Tom Boonen (BEL) same time, 3. Aidis Kruopis (LIT) s.t., 4. Mark Renshaw (AUS) s.t., 5. John Degenkolb (GER) s.t., 6. Tyler Farrar (USA) s.t., 7. Rudiger Selig (GER) s.t., 8. David Boucher (FRA) s.t., 9. Robert Wagner (GER) s.t., 10. Alexander Kuchynski (BLR) s.t.
Overall standings:
1. Tom Boonen (BEL) OmegaPharma-QuickStep 6hr 47min 49sec, 2. Tyler Farrar (USA) at 6sec, 3. Mark Cavendish (GBR) 8, 4. Johan Van Summeren (BEL) 12, 5. Thomas Dekker (NED) s.t., 6. Robert Hunter (RSA) s.t., 7. Mikhail Ingnatiev (RUS) at 17sec, 8. Bernhard Eisel (AUT) 18, 9. Rudiger Selig (GER) s.t., 10. Adam Blythe (GBR) 19