Bruno Alves and Hugo Almeida scored the goals in the final half hour - after Azerbaijan were reduced to 10 men - as Portugal provisionally moved up to second place in Group F, ahead of the Israel-Northern Ireland clash later.
Portugal, who had not won since last September, trail leaders Russia, who have won all their four games, by a point but have played two more games than the Russians.
The visitors, who were held to a 3-3 draw in Israel on Friday, took control early on without posing too great a threat to the home goal.
Helder Postiga had three first half chances to put Portugal in front, only to be denied by goalkeeper Kamran Agayev twice and Azeri captain Rashad Sadigov the third time.
Alves came the closest five minutes before the break when his free-kick came back off the angle of post and crossbar before fellow veteran Postiga was again thwarted by Agayev.
Azerbaijan's resistance held until forward Rauf Aliyev was dismissed just before the hour mark and a few minutes later they paid dearly as Alves headed home a Joao Moutinho corner.
Substitute Almeida was then left unmarked late on to fire home a cross from Fabio Coentrao to secure a much-needed win.