Hamilton, the pre-race favorite, found himself in third position after the first turn and had slipped down to fifth before his team ordered him into the pits to retire with a misfiring cylinder.
Rosberg, who claimed the lead in the first turn after starting third on the grid, coasted home to win by a comfortable margin.
"My start didn't feel great today and I had a lot less power than usual when pulling away, so it was obvious immediately that something was wrong," Hamilton said. "It looks like we only had five cylinders firing and, while I wanted to keep going, we had to play safe and save the engine."
Mercedes executive director Toto Wolff described the race as "a day of light and shadow."
"He had done everything right this weekend until that point and it was a situation beyond his control," Wolff said.
Hamilton's misfortunes aside, Mercedes continued its impressive performance in preseason testing and showed it has easily the quickest of the all-new turbo V6 hybrid engines introduced this season.
"We have a great car and engine, and the pace was really strong today as Nico clearly showed," Hamilton said. "Big congratulations to him and the team for achieving the win, it's a fantastic result for us.
"Of course I'm disappointed with my own race and when I think about all the work that has gone on back at our factories, it's tough to have a costly hiccup."