Having lost 13 of their last 16 matches, Shaab were just six minutes away from earning a hard-fought point, but Magrao's deft finish inside the box dashed their hopes.
The Sharjah club remain in 12th spot in the standings, level on seven points with the bottom two clubs Kalba and Dibba Al Fujairah, while Dubai (19 points) have moved up to seventh in the table, leapfrogging both Al Wasl and Al Wahda. Marius Sumudica, the Shaab coach, was disappointed after the game, claiming his team did not deserve to lose.
"Before the game, I told my team, 'This Dubai team is very dangerous in free kicks and I was afraid about it'," the Romanian said.
"Unfortunately, we conceded a free kick after 84 minutes, Dubai scored from it and took three points.
"For me, the result is not correct because Shaab had two opportunities to score in the first half. A draw would have been a fair result."
Sumudica, however, sounded optimistic about the battles ahead, and is confident Shaab can keep their place in the top division if they perform the way they did last night.
"If my team play like this, the way we played today, I am sure we will take more points than we managed in the first 13 games," he said.
"The team is showing improvement, but I need results."
Shaab have made a few changes to the squad during the transfer window, releasing Michael N'dri and Rodrigo Souza Silva, and bringing in the Zimbabwean Noel Kaseke and the Portuguese Filipe Teixeira instead.
Dubai have also made a new addition to the team during the break, replacing Alhassane Keita with the Brazilian midfielder Juliano Roberto Antonello and the indisposed Simon Pierre Feindouno with Juan Quero.
According to the club, Feindouno has to be released following medical advice and they refused to elaborate.
Teixeira, who has played in the French and English top divisions earlier, made a good first impression in the Shaab jersey, marshalling their midfield and sending in some neat crosses, including one that Rodrigo Vergilio put into the net in the 27th minute.
The Brazilian, however, was flagged for offside. Vergilio was initially announced as one of the two players who was to make way for Kaseke and Teixeira.
But with N'dri out injured, the club have kept their decision on hold.
Quero, at the other end, also made an impressive debut for Dubai despite his late arrival, making a couple of attempts that were just wide off the mark.
Hassan Abulrahman also came close for the hosts in the 62nd minute, his volley from the right just missing the far post.
The Dubai No 10 then tested Motaz Abdullah with a dipping free kick in the 75th minute, and the former Al Ain and Al Wahda goalkeeper did well to punch the ball away.
Abdullah, however, could do little in the 84th minute but watch when Magrao back-heeled the ball through the crowded defence into the net.
Man of the match: Magrao (Dubai)
Follow us @SprtNationalUAE