Dovizioso's time of one minute 48.285seconds during free practice two was the quickest of both sessions in Spain, with Andrea Iannone going fastest in the opening round.
Having made a mistake during the previous race in Misano, MotoGP world championship leader Marquez is looking to get back to winning ways this weekend and, although he was back on form, the Spaniard was denied the fastest time on both occasions.
He thought he had done enough in the first session after setting the best mark on his seventh lap of nine but Iannone (Pramac Racing) and Aleix Espargaro (Forward Racing) both jumped ahead of him.
Iannone took top spot in a time of 1:48.995secs with Espargaro 0.190secs further back in second position and Marquez 0.295secs behind the Pramac rider.
Jorge Lorenzo (Yamaha), Dani Pedrosa (Repsol Honda) and Valentino Rossi (Yamaha) completed the top six, while Avintia Racing's Hector Barbera was forced to abandon his bike 10 minutes from the end when it burst into flames on the track.
The second session again saw Marquez go fastest but he was beaten the quickest time before the chequered flag came out as Dovizioso went 0.043secs clear.
Marquez's time of 1:48.328secs looked to be quick enough with team-mate Pedrosa leading the charge to catch him.
However, it was Dovizioso who achieved that as the 14th lap of his session saw his Ducati top the timesheets while Pedrosa, Iannone and Espargaro performed well again to complete the top five.
Meanwhile, Nicky Hayden's return from wrist surgery saw him claim 19th and 18th places in his two runs for Drive M7 Aspar.