Bruno Fernandes got the first leg off to a dream start at Old Trafford, only for Lorenzo Pellegrini to swiftly level and ex-Manchester City striker Edin Dzeko to give Paulo Fonseca’s side a shock half-time lead.
But United have dug deep to bounce back time and time again this season, with Cavani inspiring the latest comeback when smashing home a superb leveller just minutes into the second half.
The veteran put Solskjaer’s men ahead after an error by substitute Antonio Mirante, before Fernandes added a penalty and Paul Pogba headed home.
Mason Greenwood came off the bench to add gloss on a night when Roma’s three first-half injuries took their toll in a dramatic first leg.
The Serie A side will be hugely disappointed with the way things unravelled, especially after responding so well to Jordan Veretout’s early injury and Fernandes’ fine ninth-minute opener.
Pogba impressively spun and wriggled into space before passing to Cavani, whose first-time ball put the Portuguese playmaker through to coolly clip over onrushing goalkeeper Pau Lopez.
Roma rallied impressively and broke from a poor Aaron Wan-Bissaka throw-in, with Rick Karsdorp eventually getting in a cross from the right that Pogba handled as he attempted to block.
Furious Roma players surrounded Carlos del Cerro Grande as he hesitated about awarding a penalty, before pointing to the spot and then running over to the assistant referee to discuss the decision. The VAR confirmed handball and Roma captain Pellegrini kept his cool to beat the recalled David De Gea from the spot.
United initially responded well to the 15th-minute setback as Fernandes looked to add to his opener, before Pogba got away a shot that Lopez stopped.
Roma’s goalkeeper got got hurt in the process and Mirante came on, with their injury misfortune hitting again as Leonardo Spinazzola became their third enforced change.
But by that point, the Italians were in dreamland as they had scored minutes earlier. Poor defending was followed by ex-United man Henrikh Mkhitaryan playing a superb disguised pass through to Pellegrini, who crossed for Dzeko to score scrappily from close range.
United were rocked on their heels but Roger Ibanez would have gifted them a stoppage-time equaliser had Mirante and then ex-United defender Chris Smalling not prevented Cavani from capitalising on that brainless pass.
The 34-year-old made no mistake when he next got a sniff three minutes into the second half. Cavani peeled off the shoulder of Smalling and met a return pass from Fernandes with an excellent strike into the top right-hand corner.
Pogba was booked for catching Mirante as United looked to regain their early lead, with a Scott McTominay cross-shot just taken away from Cavani.
The Scotland midfielder’s next contribution was mishitting an attempted clearance just wide of his own goal before Smalling fired over as Roma wasted a fine chance.
It was a let-off for Solskjaer’s side, who went ahead in the 64th minute and never looked back. Fernandes just managed to prod the ball over to Wan-Bissaka, whose low shot was poorly parried by Mirante into the path of Cavani to sweep into an empty goal.
Dzeko forced De Gea into a save, only for the visitors to fall further behind as Smalling was harshly adjudged to have caught Cavani with the follow-through of his challenge. Roma fumed at the decision to award a penalty and Fernandes kept his cool to score.
Goalscorer soon became provider as the Portuguese clipped a fine cross over for Pogba to power home a header.
Roma looked punch-drunk and United took full advantage, with substitute Greenwood striking low past Mirante having been found by a fine Cavani pass in the 86th minute.