Marc Marquez set a new lap record to take pole position for the German Grand Prix, while Marco Bezzecchi withdrew after a qualifying crash.