Rantie came on as a substitute and scored the winner three minutes from time, after Siyabonga Nontshinga had given Cosmos the lead on 29 minutes, and Isaac Chansa had levelled matters with a penalty on the stroke of half-time.
Cosmos are yet to win a game this season, while Pirates are up to fifth on the table.
From the outset Cosmos knew chances would be few and far between and resorted to shooting on sight early on, but with little effect.
Two such examples came from Siyabonga Nhlapo in the third and fifth minute respectively, but both shots from just outside the 18-yard area went well wide.
After that, however, the Buccaneers took charge of the match and dominated the midfield battle, although they struggled to break down Cosmos' stubborn defence.
In the 20th minute Lucky Lekgwathi latched onto a corner-kick with a powerful header from the edge of the six-yard area, but his effort was superbly saved by Avril Phali, diving full stretch to his right to palm the ball away from danger.
Three minutes later a great individual run from Daine Klate saw him break down the right flank and supply a perfect cross to unmarked Bongani Ndulula 12 yards out from goal, but the Pirates striker tried a spectacular scissors-kick and only succeeded in scuffing his shot with the goal at his mercy.
Then in the 29th minute, very much against the run of play, a brilliant passing movement by Cosmos saw them break the deadlock.
Bamuza Sono created the chance on goal with a defence splitting pass that set Katleho Loke free inside the right edge of the 18-yard box. Loke fired a cutback into the box and Nonyshinga acted first, getting in front of his marker to side-foot the ball home from a couple of metres out at the near post.
In the dying seconds of the first 45, the referee wrongly adjudged Lehlohonolo Nonyane to have pulled down Rudolph Bester inside the box. Replays clearly showed Bester had dived to earn the penalty.
Nevertheless, Chansa stepped up to the spot and coolly slotted the ball home into the top left corner to make it 1-1.
Cosmos started the second half the better of the two teams, and came close to taking the lead again with two attempts on goal within a minute of each other.
In the 53rd minute Notshinga broke into the box and pulled the best out of Moeneeb Josephs' reflexes, as the keeper palmed his powerful 14-yard effort over the crossbar.
From the resulting corner Cosmos should really have scored their second goal but Thapelo Tshilo headed wide.
As Pirates pushed forward for the equaliser they left themselves exposed at the back and after a quick counter-attack Nonyane's free header was saved by Josephs, with his feet.
After surviving that scare Pirates did take the lead when Rantie latched onto a long ball from the back just outside the 18-yard box.
The youngster, in only his second match for Bucs, showed real composure as he drove into the box and beat one defender before firing home from 14 yards out, handing Pirates the victory.