A second-half strike from Rufat Dadasov, followed by a goal in the fifth minute of injury time from Mohir Shukurov, gave the hosts their first victory of the qualification campaign
Michael O'Neill's charges, who had Jonny Evans sent off for the foul that led to the hosts' injury-time second, were guilty of missing a host of chances at the Bakcell Arena in Baku as they slipped to their fifth defeat in Group F.
Rufat Dadasov had the Azerbaijan supporters on their feet in the 58th minute when he rounded off a neat move by side-footing beyond Roy Carroll.
And there was a late second when Mahir Shukurov capitalised on Evans' dismissal by curling home a free kick from 20 yards.
Jamie Ward twice went close for Northern Ireland in the opening period, first forcing Kamran Agayev into a close-range save before scooping over the crossbar.
Martin Paterson was also guilty of wastefulness prior to Dadasov's strike when he dragged wide from eight yards and the Huddersfield striker also hit the bar with two minutes remaining.
O'Neill welcomed Chris Brunt back from suspension, meaning Niall McGinn dropped to the bench.
Azerbaijan boss Berti Vogts, meanwhile, included Vuqar Nadirov and Qara Qarayev in their starting XI, both having been named among the substitutes for the 1-1 draw with Israel in September.
The visitors controlled possession in the early stages and Brunt nearly forced a breakthrough in the ninth minute when he spun in the box and fired an effort at Agayev.
The West Brom winger was involved again soon after as his fierce 25-yard strike was beaten away by the goalkeeper.
Northern Ireland continued to press and Ward's 23rd-minute header from Paterson's centre forced a superb point-blank save from Agayev.
The visitors' profligacy was almost punished when Dadasov flashed an eight-yard strike wide of the post.
And Azerbaijan came even closer on 28 minutes as Rauf Aliyev hit a sweet back-post volley towards the near post, forcing Roy Carroll into a wonderful reflex save.
But Northern Ireland finished the half the stronger and had two further chances to take the lead.
First Ward scooped a loose ball over the crossbar, before Paterson dragged wide after his strike partner's through ball put him one-on-one with Agayev.
Azerbaijan came out the stronger side after the break, though, and Dadasov should have done better when he sidefooted Shukurov's cross wide.
Soon after, however, the forward did break the deadlock. Araz Abdullayev slid an intricate ball into Aliyev's path and his low cross was converted at Carroll's near post.
Northern Ireland looked for an immediate comeback and Gareth McAuley looped a header onto the roof of the net before Oliver Norwood curled a 30-yard free kick just wide.
Paterson went closest in the 88th minute, receiving Steven Davis' pass before unleashing a vicious effort against the woodwork.
But Evans then saw red for an off-the-ball challenge on Aliyev and Shukurov's resulting free kick put the result beyond doubt.
Azerbaijan finish their campaign with a home fixture against Fabio Capello's Russia on Tuesday, while Northern Ireland travel to Israel looking to avoid finishing bottom of the group.