The visitors twice came from behind and snatched the winner in injury time to stun the Buccaneers, relegating the Soweto giants to third place in the final standings.
Pirates had controlled the game throughout, but poor defending saw them lose at Orlando Stadium on Saturday.
Tlou Segolela, called up to the Bafana Bafana squad this week, opened the scoring for the Buccaneers in the 18th minute with a well-struck header.
Maritzburg scored an equaliser against the run of play in the 58th minute through a stunning long-range strike from Heinrich Isaacks, but Pirates were determined to end their league campaign on a high-note as Khethowakhe Masuku netted three minutes later.
Maritzburg equalised again when Ryan de Jongh scored his side's second with three minutes left on the clock, but the visitors had the final say as Malajila fired home the winner with time running out.
Maritzburg picked up three points to end the league season in 11th position.
Pirates produced their first serious threat on goal when Happy Jele whipped a ball into the area, and Segolela's header found the back of the net to make it 1-0 to the hosts in the 18th minute.
Chance to double the lead
Four minutes later, from a Segolela corner which was allowed to bounce in the area, Collins Mbesuma was left in a one-on-one situation with Maritzburg keeper Shuiab Walters, but the shot-stopper managed to get his body in the way and block the effort.
Maritzburg made an attempt to pull a goal back, and in the the 24th minute De Jongh tried his luck from range, but his well-struck effort just missed right of the target.
Two minutes later, De Jongh turned provider as he crossed for Orlando Smeekes, but the ball fell just ahead of Smeeks and the attempt was easily gathered by Senzo Meyiwa in the Pirates goal.
A minute before the break Segolela had a chance to double the lead with a run into the area, but his attempt from a tight angle was pulled across the face of goal.
Mabena had a powerful close-range effort saved in the 50th minute as Pirates looked to double their advantage after the interval.
A minute later Jele had a free header from close range but was unable to find the target.
In the 53rd minute, Masuku went for goal from a free kick 25 metres out, and Walters deflected the ball against the post and out for a goal kick.
Maritzburg substitute Isaacks, with nothing on in the midfield, ran towards the box on the hour mark, and before entering the area unleashed a fierce strike, which rocketed into the top corner to level the scores at 1-1.
Moments later, Pirates cut the Maritzburg defence in half, and the shot fell to Masuku. This time he made no mistake as he banged the ball home to regain the lead for his side.
The next equaliser came for Maritzburg United with three minutes left after a goalmouth scuffle, with De Jongh able to edge the ball over the line.
Malajila netted in second-half injury time to snatch three points for the visitors. – Sapa