Mjallby had gone top at the weekend after they beat Brommapojkarna and previous leaders AIK and Hammarby drew 0-0, but a slip up away at Hammarby would see them drop back down again.
A difficult evening looked to be in store as Hammarby dominated the opening minutes at 3Arena, but Mjallby weathered the storm and took their first real chance when it came in the 21st minute.
Ludwig Thorell controlled a ball over the top superbly, drove to the edge of the area and steered his shot low and beyond the reach of Warner Hahn in the hosts' goal.
Hahn and his opposite number, Noel Tornqvist, continued to be tested in a first half that became increasingly heated, before Hammarby found an equaliser shortly before the break.
Sebastian Tounekti squared the ball to Montader Madjed, and from 25 yards he curled the ball into the bottom corner as Tornqvist stood rooted.
Nahir Besara struck the post approaching the hour mark as the Bajen looked to capitalise on their increasing pressure, only for the visitors to retake the lead five minutes later.
Abdoulie Manneh played a through ball to Herman Johansson, who cut the ball back to Alexander Johansson and he tapped home his fourth of the season.
Hammarby created few clear chances late on, allowing Mjallby to hold on for their third win in a row and their eighth in their last nine league outings. The home side stay fourth with only one win in their last four.
Mjallby's win ruled out the chance of AIK ending the night at the top of the standings, but they lost further ground by drawing 0-0 away at Malmo, their second goalless draw in five days.
The visitors could count themselves fortunate to still be level at the break, as Pontus Jansson, Isaac Kiese and Anders Christiansen all came close to breaking the deadlock for Malmo in the first half.
AIK regrouped and created their best chance of the game early in the second half, but after a flowing move that involved several players, Anton Saletros somehow missed the target from eight yards with the goal gaping.
The home side tried their luck a few more times late on, but neither team could find a way through.
Fifth-placed Malmo are now unbeaten in four matches but have won just three of their last nine, while AIK remain unbeaten all season but have drawn four of their last five.
Follow the Allsvenskan on Flashscore.