Trinity really brought the game to Mark McHugh's side early on, scoring two converted tries inside the opening 20 minutes. Peter Hastie sandwiched in a penalty at the other end.
The students started with a maul score, well finished by flanker Alan Francis, and then as good a try as you will see, created by a Ronan Quinn intercept and kick chase and it was scrum half and skipper Louis O'Reilly who was up in support to round off a sweeping move.
With 23 minutes on the clock and against the run of play, Quinn intercepted a pass just outside the Trinity 22 and, suddenly, Lansdowne were desperately scrambling back into their own half.
The flying winger battled to collect his own chip kick, offloading brilliantly for Marcus Kiely to link with O'Reilly who had the pace to finish near the left corner.
However, Lansdowne responded in impressive fashion, their efficiency in the opposition half seeing them reel the students back in.
Well-worked tries from out-half Hastie and number 8 Boyle reduced the deficit to just one point. Cormac Foley sent his half-back partner over to the left of the posts, Hastie doing well to slip past a couple of forwards from close range.
Missed conversions meant it was 14-13 to Trinity at half-time, and the students brought great energy to the start of the second half, earning a scrum just a few metres out.
Carries from newly-introduced Leinster lock Jack Dunne and hooker Mark Nicholson brought them up close to the posts, before replacement Jamie Berrisford rumbled over, aided by Dunne and Francis in support.
To their credit the hosts kept coming, number 8 and former Ulster player Clive Ross putting in a massive shift all game. He led the charge for the headquarters club.
Lansdowne knocked on the door for much of the final quarter, as ill-discipline almost cost the visitors a famous win on the all-weather pitch.
McHugh's charges built momentum again with tries from replacements Eamonn Mills and Kavanagh, which put them ahead for the first time. Egan booted over a penalty between those scores.The Trinity defence was sucked in when defending a maul, Lansdowne hooker Luke Thompson going close to scoring before space opened up on the right and Andy Marks got his pass away for Mills to go over untouched.
Although Egan's clever restart won his team back possession, they later knocked the ball on and it looked as if Lansdowne were within reach of their fifth win of the season.
Trinity, though, turned the tables again when winning a crucial scrum penalty. Egan capped off a brilliant individual performance by splitting the posts and sparking wild celebrations amongst his team-mates.