Birthday boy Jorge Lorenzo raced to pole position in an incident-packed final qualifying session for his home country Spanish MotoGP.