Romano Fenati secured just the second pole position of his career at the Qatar GP with a sensational last-gasp lap.