The 30-year-old German, who had seen his advantage cut to nine points after three poor races, came home comfortably clear of second-placed compatriot Sebastian Vettel of Ferrari.
His Mercedes team-mate and defending champion Lewis Hamilton came home a frustrated fifth after a race dogged by technical problems on the tricky new Baku street circuit as Azerbaijan hosted its maiden Formula One race.
After two successive wins had lifted him back into contention for a fourth title, Hamilton slipped back to 24 points behind Rosberg whose return to form brought him his 19th career victory.
Valtteri Bottas finished sixth for Williams ahead of Australian Daniel Ricciardo and his Red Bull team-mate Max Verstappen with Nico Hulkenberg ninth for Force India and Felipe Massa 10th in the second Williams.
More From This Section
Rosberg now has 141 points in the title race and Hamilton 117.
"The weekend went perfectly for me, an awesome day," said Rosberg.
"An incredible circuit," said Vettel. "High speed corners and very close -- and for us, a great recovery and now I've had two second places in a row. We are coming along ok now."
Hamilton held steady in tenth for two laps before swiftly rising to eighth before the first round of pit-stops.
Rosberg built a lead of nine seconds in the opening six laps as Ricciardo followed Verstappen into the pits, switching from super-softs to softs.