Dani Pedrosa returned to winning ways after a three-man battle at the Sachsenring.
The Repsol Honda rider saw off Yamaha's Jorge Lorenzo and his team-mate Casey Stoner to win for the first time since
Lorenzo closed the gap on Stoner at the top of the championship by taking second, with Andrea Dovisioso fourth.
British rider Cal Crutchlow was 14th, with Valentino Rossi's poor form continuing as he came home in ninth.
Pole-sitter Stoner managed to get ahead by lap five but he was unable to break clear of the chasing quartet and Lorenzo's brave move saw him muscle back past with 17 laps left.
Pedrosa then surprised Stoner by overtaking him over the start/finish line.
Spaniard Pedrosa - now fully fit after a spell on the sidelines - then took advantage of an error from Lorenzo to take the lead with nine laps left before Stoner followed him through to relegate Lorenzo to third.
Lorenzo then pulled off a fine move on the final corner to take second place from Stoner and close the gap at the top of the standings to only 15 points.
The championship race could go to the wire, especially after the two contenders earlier ruled out racing in Japan later this year.
Pedrosa told BBC Sport: "It was an unbelievable race. I got into a good rhythm at the end and was able to pick up a perfect result.
"I wasn't expecting this at all and I am very happy. This season has been very hard for me but to come back and win now is fantastic."
Lorenzo added: "It was a fantastic race.
"I was struggling with my left hand and didn't have the power to push hard but at the last corner I took a huge risk and made a miracle to get past Casey into second."
In the day's earlier races, Marc Marquez won for the third Moto2 race in a row, while there was an extraordinary finish in the 125cc class.
Hector Faubel and Johann Zarco finished in a dead heat and were awarded an identical time.
A photo finish could not separate the riders but Faubel was given the victory after he clocked a faster lap during the race.
German MotoGP results:
1) Dani Pedrosa (Spn) Repsol Honda 41'12.482
2) Jorge Lorenzo (Spn) Yamaha 41'13.959
3) Casey Stoner (Aus) Repsol Honda 41'14.050
4) Andrea Dovizioso (It) Repsol Honda 41'22.995
5) Ben Spies (USA) Yamaha 41'23.201
6) Marco Simoncelli (It) 41'23.405
7) Alvaro Bautista (Spn) Suzuki 41'39.933
8) Nicky Hayden (USA) Ducati 41'39.992
9) Valentino Rossi (It) Ducati 41'40.058
10) Colin Edwards (USA) Tech 3 Yamaha 41'45.973
1) Casey Stoner (Aus) Repsol Honda 168 points
2) Jorge Lorenzo (Spn) Yamaha 153
3) Andrea Dovizioso (It) Repsol Honda 132
4) Valentino Rossi (It) Ducati 98
5) Dani Pedrosa (Spn) Repsol Honda 94
1) Marc Marquez (Spn) Suter 41'37.457
2) Stefan Bradl (Ger) Kalex 41'38.353
3) Alex de Angelis (RSM) Motobi 41'38.844
1) Hector Faubel (Spn) Aprilia 39'57.979
2) Johann Zarco (Fr) Derbi 39'57.979
3) Maverick Vinales (Spn) Aprilia 39'58.251