Dani Pedrosa won the German MotoGp in dramatic circumstances after his Honda team mate Casey Stoner, who started in pole position crashed out of the race on the last lap of the Sachsenring.
The Spaniard claimed his first victory of the season, with compatriot Jorge Lorenzo second and Italian Andrea Dovizioso third.
Stoner and Pedrosa, swapping the lead throughout the race, had both turned up the pressure during the final few laps, with the Australian in determined mood and hoping to open up a lead in the championship.
However, the defending champion slid off the track while attempting to overtake Pedrosa, allowing championship challenger Lorenzo to claim second place and some vital points in the title race.
Lorenzo now enjoys a four-point lead on top of the table and, talking to the BBC afterwards, cheerfully admitted luck had played its part.
"Things can change completely in two races," Lorenzo said. "At Assen we have zero points and were very disappointed but then we have luck from Casey's crash today.
"I would have been happy to finish third as the bike was not so good but we were lucky."
Dovizioso, riding for Tech 3 on a Yamaha, held off the challenge of U.S. Yamaha driver Ben Spies to take third spot.
Alvaro Bautista, starting the race at the back of the grid as punishment after colliding with Lorenzo at the Dutch MotoGP last weekend, finished seventh.