World champion Valentino Rossi won a fantastic four-way scrap to take victory in the German MotoGP race.

The Italian held off the challenges of fellow countryman Marco Melandri, American Nicky Hayden and Spaniard Dani Pedrosa to take the win in front of 93,748 spectators at the Sachsenring.

Rossi had started the race in 10th on the Camel Yamaha but cut his way through the field to take the lead on the 13th of 30 laps and was able to keep Melandri's Fortuna Honda and the Repsol Hondas of Hayden and Pedrosa behind him.

Melandri grabbed the lead with three laps to go but Rossi was back in front later in the same lap and held his advantage to the chequered flag for his fourth race win of the season.

Rossi admitted he was surprised to win after struggling with the set-up on his Yamaha M1 during practice and qualifying.

'This result is quite unbelievable for me and for my team. During the practice I was always behind and struggling with the bike,' he said.

'A very big thank you to my team, we changed a lot of things (on the bike) this morning and this afternoon. We did a great job with Michelin, they helped us a lot.

'Escape (from his pursuers) was impossible and I had another great battle with Marco on the last lap.'

Hayden leads the championship standings with 169 points, ahead of Rossi on 143, Pedrosa on 140 and Melandri on 134.

Yuki Takahashi won the 250cc race with a last-lap pass on Alex de Angelis after closing down the long-time race leader.

Master Aspar Aprilia's De Angelis had broken away to leave a four-man group involving Takahashi to battle over second place.

But the Japanese rider closed in on his San Marino rival and snatched the lead going into the final corner before crossing the line just ahead of De Angelis.

Humangest Honda rider Takahashi has moved up to third in the series, with Spaniard Jorge Lorenzo in the lead after finishing the race third on the Fortuna Aprilia.

Italian Andrea Dovizioso, Takahashi's team-mate, is second in the series standings after finishing the race in fourth.

1  V Rossi Yamaha 41:59.248
2  M Melandri Honda 41:59.393
3  N Hayden Honda 41:59.514
4  D Pedrosa Honda 41:59.555
5  L Capirossi Ducati 42:08.012
6  S Nakano Kawasaki 42:08.395
7  C Vermeulen Suzuki  42:15.856
8  S Gibernau Ducati 42:15.896
9  C Checa Yamaha 42:16.345
10 J Hopkins Suzuki 42:17.034

1 N Hayden Honda 169
2 V Rossi Yamaha 143
3 D Pedrosa Honda 140
4 M Melandri Honda 134
5 L Capirossi Ducati 118
6 C Stoner Honda 91
7 C Edwards Yamaha 77
8 S Nakano Kawasaki 67