The Scarlets fell behind before recovering to take a 16-9 lead into half-time. Rhys Priestland kicked two penalties, converted a penalty and tagged on a late drop goal.
But Pienaar whittled the deficit down to 16-15 for Ulster, and in the final quarter the Springbok star emerged as the match winner.
The Scarlets, who lost away to Connacht last time out, welcome back a number of players from international duty - including the likes of new Wales caps Priestland and Josh Turnbull and Scotland's Sean Lamont.
Ireland's Paddy Wallace, Andrew Trimble and Tom Court returned for Ulster. The sixth and final change to the Ulster team that lost to the Ospreys saw Ireland Under-20 international Paddy Jackson come in as a late replacement for Ian Humphreys (shoulder) at out-half.
In wet and windy conditions, it was the visitors who seized the early initiative. Pienaar converted two penalty attempts and made a 30-metre break from a lineout that could have resulted in a try. But Scarlets full-back Dan Evans was alive to the danger, and Court knocked on.
The Scarlets settled after good work from the forwards and a subsequent penalty from out-half Priestland opened their account. Priestland's second successful penalty was followed by penalty try in the 22nd minute.
Gareth Maule, the Scarlets' try scorer against Connacht, forced Adam D'Arcy into the concession of a five-metre scrum.
The forwards slugged it out through three scrums before Ulster gave way - Thomas Anderson was singled out for not binding - and referee Andy Macpherson awarded a penalty try, the first for the Llanelli outfit since their first game at Parc y Scarlets in November 2008.
Priestland popped over the conversion for a 13-6 scoreline. The seven-point gap remained for half-time, with Pienaar notching his third penalty - on the back of a lovely show-and-go from Jackson - and Priestland giving his side the final say with a drop goal.
Nigel Davies' men exerted some pressure on the cusp of half-time, attacking through a series of phases, but Ulster were up to the task and dug their heels in.
The hosts had to settle for Priestland's drop goal. It was a cracking strike from the Scarlets number 10 who dropped back into the pocket after some clever play from Martin Roberts and a break along the touchline from Lamont.
The rain came down heavier for the second half and the error count increased for both sides. Pienaar, who kicked in the absence of Humphreys, made a real scrap of it with penalties after 48 and 60 minutes.
Ulster, with their lineout proving solid, were visibly growing in confidence. Jackson's withdrawal saw Paul Marshall introduced at scrum half and Pienaar move to the out-half berth.
Although kicking well on the night, Priestland pushed a late penalty from the right wing wide of the uprights. With time ticking away, the Scarlets must have thought they had done enough to seal the match points.
The victory would have taken Davies' side up to second in the table, but when number 8 Ben Morgan infringed at a scrum, Pienaar had one last-gasp chance to win it.
Two metres inside his own half, the South African international held his nerve to decide this titanic tussle and give Ulster an important victory in their fight to reach the Magners League play-offs.
Speaking after the game, Scarlets boss Nigel Davies said: "We never totally controlled the game, although I thought we did enough in most phases of the game to win it. But unfortunately our lineout was nowhere near.
"At times it was shambolic, which is so frustrating. It's quite simple if you want to win games, you have to do your basics well.
"People will talk about penalties that were questionable, but we are not in control of that. We are, however, in control of our set piece and that was what cost us. We got just about everything wrong in our lineout game and we did not have a platform to play off at all by the end of the game.
"There's a lot of disappointment and frustration to deal with right now, but the boys will be in on Sunday and the only way to deal with losses like these is to get right back straight away."
"There's still everything to play for, a couple of wins can make all the difference in this league and it can change very quickly - we are still at the top end of the table.
"It is a huge blow for us and we have to accept that. We have to get back quickly and make sure that we make a big difference and performance on Thursday night against Edinburgh."
|Scarlets Score Card|
|Ulster Rugby Score Card|