For long periods at Sardegna Arena it looked as though the situation would become even bleaker, with goalkeeper Alessio Cragno in inspired form, and Lukaku, Alexis Sanchez and Alessandro Bastoni all wasteful.
Riccardo Sottil's expert 42nd-minute finish had Cagliari on course for three points but Barella's wonderful effort preceded D'Ambrosio nodding in from close range and Lukaku completed the comeback to make it four straight Serie A wins for Inter, who are two points adrift of leaders Milan having played a game more.
Cragno made a fine double stop from Lukaku and Christian Eriksen - making a first start since October 31 - and denied the latter again after Bastoni wastefully blazed over from seven yards.
Sanchez saw a point-blank header saved by the keeper's feet and Cragno kept out the Chilean forward's stinging effort shortly after.
Barella was just off target with an acrobatic effort and Inter were punished after 42 minutes when Sottil finished brilliantly on the volley after his initial effort was blocked.
Leonardo Pavoletti should have added a second from close range before the break, while Cragno again came to Cagliari's rescue when palming away substitute Ashley Young's bending effort on the hour.
Samir Handanovic's save from Joao Pedro was crucial as Barella brilliantly volleyed home against his former club from a cleared corner in the 77th minute and another set-piece proved Cagliari's undoing when D'Ambrosio met Barella's corner six minutes from time.
Alberto Cerri scuffed wide as Cagliari almost replied but Lukaku ran the length of the field to place into the empty net when Cragno had come up for a last-gasp corner to complete the turnaround.
What does it mean? Conte earns more time to build his skyscraper
Previewing this fixture, Conte - whose side finished second and reached the Europa League final in his debut campaign in charge - pleaded for patience from Inter's success-hungry fanbase, saying he needed time to build a "skyscraper" having laid some initial foundations.
Had they lost here after their Champions League exit the time may not have been afforded but a late revival was just the tonic Inter needed. They had 21 shots, 11 of which were on target, and almost 58 per cent of possession - in truth it was a deserved win.
Classy Cragno unfortunate for Cagliari
The margins in football are fine and on another day this could have been a resounding Inter win. As it was Cragno produced a performance of the highest order, making eight saves in total to keep Inter at bay before the visitors finally found a way through.
Barella sparks the fightback
Barella came through the youth ranks at Cagliari and opted not to celebrate against his former club - a nice touch but it was a shame his excellent strike was met with a muted reaction.
It was from his corner that D'Ambrosio scored a minute after entering the fray, and in total he had two shots on target, claimed an assist and had a passing accuracy of 82 per cent.
Key Opta Facts:
- Only Manchester United (15) have gained more points from losing position than Inter (10) in the top-five European Leagues this season.
- Inter have scored 29+ goals in their first 11 Serie A matches for the first time since 1958-59 (30 in that case).
- For the first time in hus career Nicolo Barella has both scored and provided assist in the same Serie A match.
- Since 2015-16 only Aleksandar Kolarov (17) has scored more than Danilo D'Ambrosio (16) among defenders in Serie A.