Rossi then moved into the lead but could not shake off Dovizioso in second place.
Eventually the world champion managed to open up a decent gap on the field, and Dovizioso's attentions turned to holding off the challenge of Hayden in third.
Lorenzo, who admitted he had come into the weekend still not fully recovered from a pre-season hand injury, had a quiet race until he suddenly leapt into contention with two laps to go, bursting into second place.
Qatar win 'like gold' - Rossi
Hayden and Dovizioso then had a fierce battle for third, with the Italian edging out the American off the podium by just 0.011 seconds right on the finish line.
Rossi's victory was the 104th of his career, and he admitted it had been hard work.
"It was a tough race, very very difficult," he said afterwards.
"Stoner was incredibly fast and I thought he was going to win so when I saw him make a mistake I knew we had to continue to push.
"It was tough because we struggled with the engine and we were slow on the straights.
"Dovizioso was taking half a second a lap from me on the straight so I had to ride very hard on the infield.
"It is a bonus 25 points with Stoner not finishing and it is a great start to the season for us."
Lorenzo, who finished runner-up to Rossi in last season's championship, was thrilled with second place after his injury-blighted pre-season.
"I feel so happy with second, more than some victories in the past," he told BBC Sport.
Japan's Shoya Tomizawa won the inaugural Moto2 race, ahead of Alex Debon and Jules Cluzel, with Great Britain's Scott Redding back in 23rd, and the 125cc race was similarly disappointing for the British riders.
Bradley Smith could only come home in eighth place and Danny Webb 11th, as Nico Terol, Efren Vazquez and Marc Marquez ensured an all-Spanish podium.
Qatar MotoGP result:
1 V Rossi (It) Fiat Yamaha 42:50.099 2 J Lorenzo (Sp) Fiat Yamaha 42:51.121 3 A Dovizioso (It) Repsol Honda 42:51.964 4 N Hayden (US) Ducati 42:51.975 5 B Spies (US) Tech 3 Yamaha 42:54.002 6 R de Puniet (Fr) LCR Honda 42:59.421 7 D Pedrosa (Sp) Repsol Honda 43:06.607 8 C Edwards (US) Tech 3 Yamaha 43:09.966 9 L Capirossi (It) Suzuki 43:10.992 10 H Aoyama (Jpn) Honda 43:11.199 11 M Simoncelli (It) San Carlo Honda Gresini 43:21.737 12 H Barbera (Sp) Aspar Ducati 43:22.672 13 M Melandri (It) San Carlo Gresini Honda 43:30.879
Moto2 race result:
1 S Tomizawa (Jpn) Suter 41:11.768 2 A Debon (Spn) FTR 41:16.424 3 J Cluzel (Fr) Suter 41:16.557
125cc race result:
1 N Terol (Spn) Aprilia 38:25.644 2 E Vazquez (Spn) Derbi 38:28.039 3 M Marquez (Spn) Derbi 38:28.064 8 B Smith (GB) Aprilia 38:39.363
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.