The Brazilian became the first player for a team from Azerbaijan to score in the competition outside of qualifiers, but earlier goals from Kostas Manolas and Edin Dzeko were enough to give the visitors the win.
Qarabag shipped six in their opening Group C match against Chelsea and will have feared the worst when Manolas headed in after just seven minutes, before Dzeko netted a second before a quarter of an hour had been played.
Eusebio Di Francesco's side, who were held by Atletico Madrid on matchday one, eased off at 2-0 and allowed Qarabag to snatch a lifeline with a goal in the first Champions League match to be staged in the country.
Gurban Gurbanov's men were arguably the better side for much of the rest of the match but were unable to test Alisson in the Roma goal, allowing the Serie A side to make it four points from two games.
They move top of the group but could be supplanted depending on the result between Atletico Madrid and Chelsea in the Spanish capital. Qarabag, meanwhile, stay bottom.
Roma took full advantage of a goalkeeping error from Ibrahim Sehic to take the lead seven minutes in. The Bosnia-Herzegovina international punched a corner straight to the feet of Lorenzo Pellegrini, whose cross was expertly steered into the bottom-corner by Manolas' diving header.
The visitors doubled their lead eight minutes later, with Dzeko controlling Stephan El Shaarawy's flick into the box before blasting in off the crossbar from close range for Roma's 100th Champions League goal.
Roma seemed to let complacency creep in after Dzeko's strike, allowing Qarabag to spring dangerous counter-attacks on two occasions after losing the ball to the home side's good pressing game.
They failed to heed the warnings and were duly punished on 28 minutes, with Dino Ndlovu robbing Maxime Gonalons and feeding Pedro Henrique in the box, who steadied himself before firing past Alisson from 12 yards out.
The home side, buoyed by their historic goal, continued to match Roma for intensity in the early part of the second half, although Sehic had to make a fine stop to deny Bruno Peres a third goal as he surged into the penalty area on the break.
Daniele De Rossi was introduced off the bench and the midfielder's experience seemed to give Roma an extra measure of control, with Alisson's goal largely untroubled despite one or two promising Qarabag moves.
Dzeko fluffed a half-volley that could have made the win safe with 10 minutes left, but the visitors eased through to full-time unscathed to claim an important win.