Nico Rosberg denied world champion team mate Lewis Hamilton a fifth pole position in a row by seizing the top slot for Mercedes at the Spanish Grand Prix.

Hamilton, who leads the German in the Formula One standings by 27 points after three wins in four races, lost out for the first time this season and had to settle for second on the starting grid.

The pole on a sunny afternoon in Barcelona was the 16th of Rosberg's F1 career, his first since Abu Dhabi last November, and came as a timely boost in a battle that has seen Hamilton take the upper hand.

"I needed it sooner rather than later," the German told reporters. "It is one step in the right direction to winning the race this weekend. It was a good day in the office."

Ferrari's Sebastian Vettel will line up in third place with Finland's Valtteri Bottas, in a Williams, alongside on the second row.

The crowd, although sparse in the main grandstands, were cheered by Toro Rosso's Spanish rookie Carlos Sainz taking fifth place on the grid on his home debut.

Starting grid (top-10):

1. Nico Rosberg - Mercedes
2. Lewis Hamilton - Mercedes
3. Sebastian Vettel - Ferrari
4. Valtteri Bottas - Williams-Mercedes
5. Carlos Sainz Jr - Toro Rosso - Renault
6. Max Verstappen - Toro Rosso - Renault
7. Kimi Raikkonen - Ferrari
8. Daniil Kvyat - RedBull - Renault
9. Felipe Massa - Williams-Mercedes
10. Daniel Ricciardo - RedBull - Renault

Source: Reuters