Australian Miller, on a factory Ducati, chalked up a time of 1min53.145 seconds during the most optimum conditions in the second session under the Losail circuit floodlights.
He edged his Italian teammate Bagnaia by 0.313 seconds and France's Zarco (Ducati-Pramac) by 0.392 seconds.
"I'm feeling really comfortable with the bike this evening, we changed a little bit and I felt better at the end of FP1 in the daytime, but you know the track temperatures and air temperatures were crazy high," Miller said at the end of the day.
"It's kind of hard to set the bike up for both, so I'm mainly focussing on the evening session but I was out there punching the laps out trying to shake out the cobwebs from last week and was able to do the lap time at the end there that was a kind of 'do or die' moment."
France's Fabio Quartararo (Yamaha) came fourth, 0.438 seconds off the pace ahead of Ducati-Pramac's rookie rider, Spaniard Jorge Martin who came in fifth, 0.448 seconds after Miller.
Spain's world champion Joan Mir (Suzuki) was 13th at 0.867 seconds off the pace, and seven-time MotoGP champion Valentino Rossi (Yamaha-SRT) was only 14th, 0.967 seconds behind.
Only the top 10 in the first three practice runs qualify directly for the second and final round of qualification on Saturday during which pole position is up for grabs.
The others will attempt to rejoin the leading pack during the first round of qualification Saturday from 17:00 GMT.
However it will be challenging for Mir and Rossi to improve their times during free practice three on Saturday from 12:15 GMT when the track will be hotter than in the first two outings giving less grip.
Six-time MotoGP champion Marc Marquez of Honda is still out with a fractured arm after falling last summer.
Combined standings from the first two free practices of the MotoGP Doha Grand Prix in Qatar
Losail circuit (5.380 kilometres):
1. Jack Miller (AUS/Ducati) 1:53.145
2. Francesco Bagnaia (ITA/Ducati) 1:53.458
3. Johann Zarco (FRA/Ducati-Pramac) 1:53.537
4. Fabio Quartararo (FRA/Yamaha) 1:53.583
5. Jorge Martin (ESP/Ducati-Pramac) 1:53.593
6. Aleix Espargaro (ESP/Aprilia) 1:53.646
7. Franco Morbidelli (ITA/Yamaha-SRT) 1:53.699
8. Alex Rins (ESP/Suzuki) 1:53.713
9. Maverick Vinales (ESP/Yamaha) 1:53.872
10. Stefan Bradl (GER/Honda) 1:53.914