Lewis Hamilton gets out of his stricken Mercedes Image Credit: AP

Baku: Formula One championship leader Nico Rosberg claimed pole position for the European Grand Prix after his Mercedes teammate Lewis Hamilton crashed out of qualifying in an error-strewn performance on Saturday.

Qualifying was red-flagged when Hamilton clipped his right front wheel on a wall near the Baku fortress in the twisty old-town section of the street circuit. The reigning world champion qualified 10th.

Force India's Sergio Perez was second but will take a five-place grid penalty for changing his gearbox after also hitting a wall at the end of pre-qualifying practice and severely damaging the rear of the car.

Red Bull's Daniel Ricciardo qualified third ahead of Ferrari's Sebastian Vettel and Kimi Raikkonen in fourth and fifth but all will move up a spot due to Perez's demotion. Ricciardo and Vettel had the same time down to the thousandth of a second. Ricciardo was placed in front of Vettel as he finished the lap first.

Rosberg's pole and Hamilton's mistake again flipped the momentum in the title fight between the Mercedes drivers. Hamilton had won the past two races to slice the German's points lead from 43 points to nine, but Rosberg now has a golden opportunity to re-establish a buffer.

"It was great," Rosberg said. "It was one of the more challenging sessions out there, but it worked out well.

"All weekend I was building towards it and qualifying was really optimum, it felt good."

But Rosberg wasn't getting over-confident.

"Lewis has shown very often from 10th place he can come back very strongly," Rosberg said. "In Russia he finished an easy second."

It was Rosberg's 25th pole position, moving him into outright 10th on the career list, breaking a tie with Nelson Piquet and his team director Niki Lauda.

Hamilton was the fastest driver in each of the three practice sessions but looked all at sea in qualifying, running off the track twice before finally snapping the suspension on his right front in what must count as one of the worst qualifying performances of the Briton's career.

"It's damage limitation from here," Hamilton said. "The team made a change to something overnight but I was just not on it today.

"I had a fantastic rhythm yesterday but zero today. Sometimes it happens."

To make matters worse for Hamilton, he will start the race on the tires with which he finished the Q2 section of qualifying, and he had pronounced flat spots on the front tires, which will compromise handling in the early part of the race.

Perez had mixed emotions at the events of the day, describing his final flying lap as one of the best of his career and excited by the speed of the Force India on the 2.1-kilometer (1.3-mile) long main straight, but rueful at the grid penalty which his practice crash brought about.

"I'm still a bit angry at the mistake," Perez said. "But I'm very happy too, it's a mix of feelings for me today.

"After the crash, you lose some confidence and to get it back, get back in the rhythm, it's great."

Ricciardo was in seventh place when the red flag came out with two minutes left in qualifying, and Red Bull did well to get him to the front of the queue for the restart.

"Thanks to the guys for getting me out at the front, with a clear track," Ricciardo said after grabbing a surprise front-row spot for Sunday's race.

"My first run in Q3 was pretty average to say the least, I made a few mistakes, but the last lap was good and I am really happy to bounce back."

Williams driver Felipe Massa did not make it back to the start-finish line in time to begin a last flying lap, and had to settle for sixth, while his teammate Valtteri Bottas was eighth. Toro Rosso's Daniil Kvyat qualified seventh, satisfyingly ahead of the man who replaced him at Red Bull, Max Verstappen, who will start ninth.

Tight confines of the walled-in circuit make safety-car periods highly likely in Sunday's race, possibly negating Rosberg's clear speed advantage if he manages to get away quickly.

"It is one of the easiest tracks to overtake, so there is going to be a lot of changing places I think, a lot of safety cars as well, exciting restarts," Rosberg said.