Pol Espargaro recovered from a dramatic practice incident to snatch Mugello Moto2 pole position ahead of title rival Marc Marquez.