Hamilton benefited from a slipstream from Leclerc at the start of his lap to beat his team-mate by 0.074 seconds.
The seven-time champion told his engineer there were “some good learnings there” – an apparent reference to the benefit of the tow, and Ferrari are considering employing it to gain grid positions in qualifying on Saturday.
Leclerc has been on pole position for the past four races in Baku, where his excellence on street circuits and in qualifying is at its most extreme.
McLaren’s raw pace was not seen because of the errors made by both drivers on what should have been their fastest laps.
But on the longer, race-simulation runs later in the session, Piastri was fast, so the championship leaders can be expected to remain the team to beat over the weekend.
Mercedes drivers George Russell and Kimi Antonelli were third and fourth fastest, ahead of Haas’ Oliver Bearman – two licence points short of a one-race ban – and Red Bull’s Max Verstappen.
Russell was another to have an incident, with a wild oversteer moment out of Turn 12, the exit of the section around Baku’s medieval castle. The Mercedes hit the barrier but the car was undamaged.
Racing Bulls’ Liam Lawson, the second Haas of Esteban Ocon, Williams’ Alex Albon and Norris completed the top 10.
