The Irish, who played superbly but lost 2-1 to Portugal in midweek after two last-gasp Cristiano Ronaldo goals, were dismal in the first half and went in a goal down after Emin Makhmudov fired a long-range bullet past Gavin Bazuna in stoppage time.
That sparked the hosts into action and they came out all guns blazing in the second half, firing a succession of crosses into the box and finally getting their reward when Duffy scored in the 87th minute.
After opening with three straight defeats, the result leaves Ireland fourth in the five-team group on one point, ahead of Azerbaijan on goals scored. Serbia are top on 10 points ahead of Portugal on goal difference. Luxembourg are third on six.