His efforts were preceded by Ruan Pienaar's first-half try - the South African fly-half finishing the contest with 22 points in total - as Ulster made it four successive wins in the RaboDirect PRO12 and consequently set up a clash with Scarlets in the play-offs.
Cardiff, meanwhile, extended their winless run away from home to four games but got off to the perfect start when scrum-half Lewis Jones released Dafydd Hewitt to race under the posts within four minutes - fly-half Rhys Patchell knocking over an easy conversion.
Ravenhill was boasting difficult conditions underfoot, as Pienaar found out when he skewed his attempt of a penalty wide on eight minutes, but the fly-half made amends seconds later.
From the restart Blues wing Harry Robinson made an uncharacteristic fumble which allowed the South African to jog his way over the line, and he converted to level the scores.
Patchell, selected in the Wales Under-20s squad for the IRB Junior World Championship, proved his credentials when he slotted home a 20th-minute penalty for the Blues and Pienaar did the same moments later to draw the hosts level again.
Both sides were resolute in defence and, with try-scoring chances few and far between in the first half, the opportunistic Patchell knocked over a superb drop goal just before the half-hour mark to give the visitors a 13-10 half-time lead.
But Ulster, who have lost just once at home all season in the RaboDirect PRO12, stormed out of the blocks in the second half and a stunning 14-minute period brought 20 unanswered points - turning the game on its head.
Trimble grabbed the hosts' second try of the evening three minutes after the restart when he powered his way to the line under three tackles.
Pienaar's boot then added a further eight points - the subsequent conversion and two penalties taking their lead to 23-13 before Trimble went over for his second try on 54 minutes.
Pienaar's high kick brought a mix-up in the Blues defence which allowed the wing to race clear and touch down while Pienaar's reliable boot comfortably converted from the touchline.
Pienaar almost added to his impressive tally but was held up on the line with five minutes remaining before Robbie Diack secured a bonus point with a late try on his 100th appearance for Ulster.
|Ulster Rugby Score Card|
|Cardiff Blues Score Card|