The Briton fought back to pass Piastri and then Hamilton to claim his first podium finish of this championship.