Hamilton won the race from pole position to strengthen his overall lead in the standings with his third win in four races, and 36th of his career. He is already 27 points ahead of Rosberg and 28 clear of Ferrari's Sebastian Vettel — the only driver to beat Hamilton so far.
"It doesn't matter who it's against, you try and beat everybody out there," Hamilton said, underlining how the F1 title race looks far from being the two-horse contest between Mercedes teammates it was last season. "It's great to be having a fight with the Ferraris."
The British driver started from pole for the first time in the desert race under floodlights and was largely untroubled, finishing ahead of Ferrari's Kimi Raikkonen and Rosberg, whose braking problem with two laps remaining let in Raikkonen for his first podium in two years.
"Ferrari gave us a really good run for our money and we will need to keep pushing as a team," Hamilton said. "We're trying to win both championships. So we won't be 100 per cent happy because we wanted to finish 1-2."
Rosberg, meanwhile, has no wins and no poles so far and has only won one race in the past 15.
"(Hamilton) had good speed today so it was impossible to get by him," Rosberg said.
Vettel looked set for a podium position until a late front wing change ended the four-time F1 champion's chances and he placed fifth behind Valtteri Bottas.
Jenson Button, last in Saturday's qualifying, did not start due to a technical problem, while Brazilian driver Felipe Massa stalled his car on his formation lap due to an electrical problem and started from the pit lane.
A late brake problem slowed Hamilton down a little on the final lap, but he crossed the line 3.3 seconds ahead of Raikkonen and 6 seconds clear of Rosberg — last year's runner-up. Hamilton stood on his Mercedes and pumped his fist in the air before leaping into the arms of his crew. He then jumped up and down in delight as he climbed onto the podium.
Raikkonen was 1.1 seconds behind Rosberg but overtook him on the outside after Rosberg went far too wide on a turn, prompting jubilant cheers in the Ferrari garage.
Rosberg said he lost his brakes at that moment and team principal Toto Wolff said the team would analyze why both cars lost brake power.
"It was a shame for Nico," Wolff said. "He did some great overtaking."
Rosberg tried to fight back, but it was too late to stop the 35-year-old Finnish driver from getting his first podium in 26 races.
Meanwhile, Australian driver Daniel Ricciardo just about got over the line in sixth place as his engine blew near the end of the final lap.
With sparks lighting up the night sky, Hamilton started well, holding off Vettel on the inside, while Raikkonen got ahead of Rosberg after the first turn.
"I got caught out a bit by Kimi at the start," Rosberg said. "After that the car felt awesome."
Vettel was the first of the front-runners to go into the pits on lap 14 to change to soft tires, by which point Hamilton was six seconds clear of Rosberg, who came in for a tire change on lap 15 and Hamilton followed on the next lap.
With 20 of the 57 laps completed, Rosberg was 1.5 seconds behind Hamilton.
Raikkonen, who did the opposite in switching from soft to medium tires, was 12 seconds behind Hamilton at the halfway stage. But the strategy worked for him late.
With some 20 laps remaining, a rare mistake from Vettel, running much too wide on a turn, allowed Rosberg past him.
Vettel came in shortly after to change a front wing.
Raikkonnen was still out on medium tires with 40 laps gone.
He switched to the quicker softs on the following lap and gained huge time. With 10 laps to go the 2007 F1 champion was only eight seconds behind Rosberg, who curtly told his engineers "please don't tell me the gap anymore."
Meanwhile, the problems continue for Toro Rosso as Carlos Sainz Jr. abandoned on lap 32 and teenage driver Max Verstappen joined him in the garage a few laps later.
In Shanghai last weekend, Verstappen retired with engine failure, as did Red Bull's Daniil Kvyat. French manufacturer Renault supplies the engines to both cars.Suggest a correction