Lewis Hamilton beats Valtteri Bottas to pole position at Spanish Grand Prix

BARCELONA, Spain -- Lewis Hamilton ended Sebastian Vettel's run of pole positions by claiming top spot for the Spanish Grand Prix, while his Ferrari rival had to settle for third.

Championship leader Hamilton edged Mercedes teammate Valtteri Bottas by 0.040s to give Mercedes a front-row lockout. After a poor early attempt by both Ferrari drivers, Vettel and Kimi Raikkonen recovered in the closing seconds to finish third and fourth.

After three practices topped by one of the Mercedes drivers, Ferrari appeared to have unleashed its true performance in qualifying as Vettel led Q1 and Q2. Friday's trend of drivers struggling on the super-soft carried over into qualifying, and Ferrari appeared to have the edge over Mercedes on the soft compound. However, Mercedes appeared to find the performance step required on the super-soft tyres in Q3, while both Ferrari drivers struggled on their opening laps on that compound.

Ferrari switched back to the soft tyres for the final run of the session to move back ahead of the Red Bull drivers, but it was not enough to beat either of the silver cars. The top six all set their quickest Q2 times on the soft tyre, meaning they will all start Sunday's race on that compound. Red Bull was sat second and third after the initial runs of Q3, but once Ferrari had made its improvements it dropped to the third row.

Max Verstappen won the intra-team battle at Red Bull, finishing ahead of Daniel Ricciardo by just 0.003s. Red Bull hoped the new parts it brought to Spain would close the qualifying gap but its drivers were four tenths behind the lead pair.

Kevin Magnussen converted the encouraging pace Haas has displayed all weekend to qualify best of the rest in seventh, edging out local hero Fernando Alonso, who put McLaren through to Q3 for the first time of the season. Renault's Carlos Sainz finished ninth ahead of Haas' Romain Grosjean.

Stoffel Vandoorne finished 0.3s behind Alonso in Q2 and it proved to be a costly margin, preventing the Belgian from joining his teammate in the top-ten shootout. Toro Rosso's Pierre Gasly finished 12th. As expected, Force India dropped down the order after its Azerbaijan Grand Prix podium, with Esteban Ocon and Sergio Perez -- the man who finished third in Baku -- finishing either side of Sauber's Charles Leclerc.

Hulkenberg was the surprise casualty of the opening qualifying session. The German was forced to bail out of his initial attempt after encountering what appeared to be a fuel pressure issue. Renault managed to turn his car around in time to attempt a final run, but he finished the session 16th -- just 0.04s slower than Stoffel Vandoorne.

Behind him was Sauber's Marcus Ericsson, who finished ahead of Williams pair Sergey Sirotkin and Lance Stroll. After a good showing in Baku, the Williams car appears to have returned to its normal level. The team's miserable session was topped off by Lance Stroll spinning out in the closing seconds of Q1, losing control of his car at Turn 13 and ending up in the wall.

Brendon Hartley failed to set a time after destroying his car in a heavy crash in final practice, meaning he will start from the back of the pack.