Leinster were denied top spot in the Guinness PRO12 after suffering their first league defeat since December at Irish rivals Ulster.
Ruan Pienaar played his final game for Ulster at an emotional Kingspan Stadium but ended his time at the province with a 17-13 win.
The visitors, though had already secured a top-two finish prior to this final round game and now host the Scarlets in the semi-final after their 10-game winning run in the PRO12 came to an end in what was effectively a dead rubber for both sides.
Tries in either half from Roger Wilson, on his last game before retirement, and skipper Andrew Trimble paved the way to victory for Les Kiss's side, who finished outside the play-offs for the first time since 2012.
On an emotional day for Ulster scrum-half Pienaar - playing his last game after seven years before going to France - the home side halted a three-game run without a win which had already realistically wrecked their top four hopes.
Leinster with British and Irish Lions Jack McGrath, Tadhg Furlong in their starting side, trailed 10-6 at half-time in a scrappy game which did not involve Ulster's Lions Rory Best, Iain Henderson and Jared Payne.
Ulster's Paddy Jackson ended up kicking two conversions and a penalty while Leinster were awarded a penalty try with Joey Carbery kicking a conversion and two penalties.
Carbery got Leinster under way with a fourth minute penalty but the home side came back shortly afterwards when Wilson barged over after Ulster had opted to scrum from a close-in penalty.
Jackson converted and Kiss's side led 7-3 after nine minutes. Leinster eventually cut Ulster's lead to one point in the 22nd minute after Carbery nailed a penalty when Wilson had failed to roll away.
The remainder of the half saw both sides come close to making a breakthrough but it all ended with Ulster on top and Jackson kicking a 40th minute penalty to put Ulster 10-6 in front.
Fifteen minutes after the restart, Ulster finally got the breakthrough and after finally securing some line-out ball they surged into Leinster's 22 with Pienaar providing the cross-kick for Trimble to dot down.
Jackson's superb touchline conversion put Ulster 17-6 in front and Leinster were then denied a score by the TMO after a great drive from Furlong.
Two minutes later, though, Leinster were awarded a penalty try which Carbery converted to cut Ulster's lead to 17-13 after 61 minutes and there were no further scores in the game with Pienaar leaving the field eight minutes later to a standing ovation.