LONDON, England (CNN) -- Fernando Alonso had written off his chances of winning the Singapore Grand Prix on the grid -- two hours later he was celebrating an unlikely "lucky" victory.
Renault driver Fernando Alonso celebrates his first win for a year at the Singapore Grand Prix.
The two-time world champion had been competitive all weekend only to suffer a mechanical problem in qualifying that left him in 15th on a track where overtaking is difficult.
But after the safety car came out in the wake of his Renault team-mate Nelson Piquet's crash on lap 15, luck turned the Spaniard's way and he found himself in with a strong chance of victory.
"We were unlucky in qualifying and very lucky in the race," Alonso beamed after the 20th win of his career. "Obviously we started at the back and the first safety car helped me a lot.
"We were competitive straight away here. We were hoping to take the benefit of this good car here but after qualifying maybe our hopes were gone already as we [he and Piquet] started 15 and 16 and you know that it is nearly over.
"Without the safety car maybe I was finishing in the same position, 15 or 14. Again, today shows that Formula One is unpredictable on a Sunday.
"But a first podium of the season and first victory as well and I am extremely happy. I think I need a couple of days to realize we won a race this year."
Behind Alonso, Nico Rosberg delivered the best result of his three-season F1 career with second place for Williams.
And it could have been even better for the German, who fell foul of the harsh ruling, which meant he was given a 10-second stop-go penalty for having to take on fuel when the pitlane was closed under safety-car conditions.
"When I saw the safety car coming out just on the lap where I had to pit, I was thinking 'this is not possible, it is every single time exactly the same thing,'" said Rosberg, who suffered a penalty for the same infringement in Canada last year.
"I was really annoyed and I thought that was it, that was the end of it. I then realized I was able to pull enough of a gap afterwards to be in a good position after my stop and go.
"I dropped to fourth and then they said to me that the guys in front still need to stop, so it was looking great again. It was me racing Fernando. I thought I might have a chance against him but he was just a bit too quick. It's still a great result for us."
Massa looked on course for the win in the opening stages before a horror pitstop saw him drive off with the fuel hose still attached to his Ferrari.
"It's all about scoring points. We came here with a one-point lead, and I could see that the Ferraris were very competitive this weekend and Felipe was driving very well.
"So it would have been tough to score more points than him in this race but fortunately the race had a couple of incidents in it which didn't benefit them.
"But we did a solid job and came back with the points so I really can't complain. I'm quite happy with seven points."