The two riders swapped positions on the final lap but it was Dovizioso, having led for much of the race on his Ducati, who secured victory by just 0.023 of a second over his Honda rival.
It ensured a repeat of last year's top two in Doha, when in another thrilling finish, Dovizioso triumphed ahead of Marquez by 0.027 of a second.
Britain's Cal Crutchlow, on another Honda, also made the podium, finishing third.
"I am so happy because everything before the weekend was so bad," said Dovizioso.
"It's nice to open like this against a champion."
The Italian had come into the Doha race concerned about the speed of his bike, but had been able to start in second place on the grid, following qualification.
He led a group of eight riders who dominated the race but was closely followed by Marquez all the way.
The Spaniard, who started third on the grid despite crashing twice over the weekend, pounced on the tenth corner of the final lap to take the lead, albeit briefly, before Dovizioso immediately took back the advantage.
"It was exactly the same as last year, I tried to be there at the end," said Marquez. "But I am happy because it's 20 points."
Crutchlow, who suffered a badly broken right ankle at the end of last season, said his third place was a great result.
"It's great to be back racing in MotoGP let alone be on the podium," said the Briton who added that he feared he might not be able to walk again following the crash in Australia last October.
Spain's Alex Rins finished fourth on a Suzuki, with legendary Italian Valentino Rossi, on a Yamaha, in fifth.
Maverick Vinales, also on a Yamaha and who started in pole position, finished seventh.
French rookie Fabio Quartararo, another Yamaha rider, finished in 16th place despite starting in fifth on the grid after being forced to start the race from the pit lane after his bike stalled in the warm-up lap.
Despite safety fears over the desert track's condition during the night race, only one rider crashed out, Britain's Bradley Smith.
Meanwhile, in the night's other races, teenager Kaito Toba snatched victory in Moto3 to become the first Japanese rider to win in that class.
Italy's Lorenzo Dalla Porta was second with Spain's Aron Canet third.
There was also an exceptionally close finish in the Moto 2 race with Italian Lorenzo Baldassarri just edging out Switzerland's Thomas Luthi to win.
German Marcel Schrotter, who started on pole, took third place.