Massa took the championship lead with his third win of the season
Brazilian Felipe Massa was handed victory in the French Grand Prix when Ferrari team-mate Kimi Raikkonen ran into problems with a broken exhaust.
Raikkonen was in control of a race dominated by Ferrari but his right-hand exhaust cracked at half-distance.
However, such was Ferrari's advantage that Raikkonen held on to second place.
Jarno Trulli marked Toyota's best race of the season with third while Lewis Hamilton was 10th after falling foul of officials for the second race in a row.
It was always going to be a difficult race for the Englishman following his 10-place grid penalty for crashing into the back of Raikkonen in the pits in the previous race in Canada.
But the 23-year-old made it even harder for himself by cutting the Nurburgring chicane in the process of passing Toro Rosso's Sebastian Vettel as he sought to make up places on the opening lap.
That led to a drive-through penalty, the most lenient punishment available to the stewards for the offence, which cost him any realistic chance of scoring points.
Sometimes you need a bit of luck, and we got that with Kimi's exhaust - it was a nice present
There will, though, be some debate about whether Hamilton deserved to penalised, with McLaren team boss Ron Dennis claiming after the race that Hamilton was already ahead of Vettel before the corner.
What was not up for debate was the superiority of the Ferraris.
It was obvious from his lap times that even had Hamilton suffered no penalties, the McLaren did not have the pace to challenge the Ferraris.
Raikkonen converted his pole position into a lead at the first corner, and set about building the gap he needed to keep his lead, knowing that he was to make his first stop two laps earlier than Massa.
Raikkonen, edging further ahead by the lap, was nearly five seconds clear of his team-mate when he stopped on lap 21.
And any faint hope Massa had of leapfrogging Raikkonen evaporated when he ran into traffic on the two laps before his stop.
Trulli drove brilliantly to hold on to third under intense pressure
Raikkonen then set about making the race his own, extending his lead to more than six seconds by lap 30, only to run into his exhaust problem, and being forced to cede to Massa.
"That was fantastic," Massa said. "I didn't expect that.
"Sometimes you need a bit of luck, and we got that with Kimi's exhaust. It was a good present.
"It was a great race. We showed our performance here, we are heading in the right direction, with the team doing a fantastic job."
For a short time, Raikkonen was two seconds off the pace, and it looked as if he might be vulnerable to Trulli and Kubica.
But as the problem stabilised, he managed to reduce his disadvantage to Massa to about a second a lap.
"I just kept losing power," Raikkonen said, "and then it came back. A few more laps and I don't think I would have finished the race.
"I had a good car all weekend, was easily on the pole, but then I have a problem with the car. I almost stopped a few times at the end.
"I've still taken eight points and I'm in a more comfortable position in the championship."
A rain shower in the last part of the race enlivened the last few laps.
The Ferraris continued untroubled, but Trulli, who has complained about the Toyota's poor handling in the wet, suddenly found McLaren's Heikki Kovalainen and BMW Sauber's Robert Kubica all over him.
But he continued to drive beautifully, and held the two faster cars off, aided by the rain abating with about 10 laps to go.
Hamilton suffered a second difficult race in a row
The rain returned for the last couple of laps, and Trulli managed to hold off one final assault from Kovalainen as they entered the Nurburgring chicane side by side on the penultimate lap.
"It was a great fight at the end with Kovalainen and I enjoyed that and it is what I want to be doing," said Trulli, whose last podium was in the 2005 Spanish Grand Prix.
"I don't think we touched, just wheel-to-wheel like we did in go-karting. I'd love to fight every race like that.
"I did my job and kept the inside line. I could see the podium and I didn't want to lose the position.
"Everybody knows me, I'm hard to pass. Sometimes you get it wrong, this time I got it right."
Trulli dedicated his win to former Toyota team boss Ove Andersson, who was killed in a rally accident last week.
Red Bull's Mark Webber held off the Renaults of Nelson Piquet Jr, having his most competitive race of the season, and Fernando Alonso for sixth place.
Alonso lost seventh to his team-mate, who scored his first points of the season, when he ran wide with two laps to go while lapping Force India's Adrian Sutil.
The win, Massa's third of the season, puts him into the lead of the championship, two points clear of Robert Kubica, with Raikkonen a further three adrift.
Hamilton, after two disastrous races, is 10 points behind Massa and in desperate need of a good result at the British Grand Prix in two weeks' time.
But in view of the superiority of the Ferraris in France, Hamilton's chances of beating the red cars appear slim at Silverstone, where their advantage should be at least as clear.
Official result of French Grand Prix at Magny-Cours:
1 Felipe Massa (Brz) Ferrari one hour 31 minutes 50.245 seconds
2. Kimi Raikkonen (Fin) Ferrari 17.984 seconds
3. Jarno Trulli (Ita) Toyota +28.250
4. Heikki Kovalainen (Fin) McLaren-Mercedes +28.929
5. Robert Kubica (Pol)BMW Sauber +30.512
6. Mark Webber (Aus) Red Bull-Renault +40.304
7. Nelson Piquet (Brz) Renault +41.033
8. Fernando Alonso (Spa) Renault +43.372
9. David Coulthard (GB) Red Bull-Renault +51.072
10. Lewis Hamilton (GB) McLaren-Mercedes +54.521
11. Timo Glock (Ger) Toyota +57.738
12. Sebastian Vettel (Ger) Toro Rosso-Ferrari +58.065
13. Nick Heidfeld (Ger) BMW Sauber +1:02.079
14. Rubens Barrichello (Brz) Honda one lap behind
15. Kazuki Nakajima (Jpn) Williams-Toyota one lap
16. Nico Rosberg (Ger) Williams-Toyota 1 lap
17. Sebastien Bourdais (Fra) Toro Rosso-Ferrari 1 lap
18. Giancarlo Fisichella (Ita) Force India-Ferrari 1 lap
19. Adrian Sutil (Ger) Force India-Ferrari 1 lap
R Jenson Button (GB) Honda 16 laps completed
Fastest lap: Raikkonen, one minute 16.630 seconds, lap 16
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.