Twelvetrees held his nerve to fire over a 40-metre kick to send a home crowd of 3,250 happy.
Curtis Rona, Will Goodrick-Clarke and Albert Tuisue scored tries for Irish with Paddy Jackson kicking three penalties and two conversion.
Irish took a fourth-minute lead with a try from Rona. An excellent kick from Jackson secured the visitors a platform deep in the opposition 22 from where debutant Nic Groom made a sharp break before Rona forced his way over.
However, it took Gloucester only three minutes to draw level when Carreras intercepted a hurried pass from Ollie Hassell-Collins to race 40 metres and score.
Six minutes later, Gloucester went ahead with a superbly created try.
Front-rowers Jack Singleton and Fraser Balmain put the defence on the back foot with a couple of surges before Mark Atkinson made a telling burst. The centre then fed Val Rapava-Ruskin whose neat off-load sent Heinz over for a try to celebrate his 100th appearance for the club.
Irish responded with a Jackson penalty before prop Goodrick-Clarke forced his way over from close range with Jackson's conversion giving his side a 15-12 lead at the end of a lively first quarter.
Gloucester conceded their fifth penalty in the opening half-hour for Jackson to extend the advantage but the hosts roared back into contention with another thrilling try.
A neat off-load from Atkinson sent Carreras away on a 40-metre run and when the ball was recycled, Moyle dummied his way over to score but Irish were back in front by the interval as Tuisue proved unstoppable from a driving line-out.
Heinz was replaced at half-time by Stephen Varney before Irish introduced Australian lock Adam Coleman, who returned for his first game following an injury in early February.
In the 50th minute Irish lock Rob Simmons was sin-binned for a high tackle on Singleton and Gloucester immediately capitalised with their bonus-point try from Rees-Zammit.
That try was the only score of an evenly contested third quarter with Irish able to bring back Simmons from the sin-bin with no further damage to the scoreboard.
Jackson missed with a long-range kick before Twelvetrees and Jackson to exchange penalties in a tense finale before Twelvetrees stepped up with the match-winner after Irish dragged down a driving maul.