Alonso never opened up a big lead but never looked in serious danger of losing it either, successfully fending off the Red Bull of Vettel and the upgraded McLaren of Jenson Button.
"It was tough. Maybe we were not the fastest in dry conditions but we were competitive to retain the lead," Alonso said. "Jenson was putting a lot of pressure."
Alonso also won the German GP the last time it was run on the Hockenheim circuit two years ago.
Vettel failed again to win his home race and he was penalized for overtaking Button from outside the track, having gone off the circuit with all four wheels with one lap remaining in the 67-lap race.
The 20-second penalty further dents Vettel's chances of retaining the title. Button moved up to second and Kimi Raikkonen to third.
"I wasn't sure if he (Button) was on the inside or not. The last thing you want to do is make contact. When we were side by side, I tried to give him enough room but it's difficult to see. I went wide," Vettel said before the ruling. "We were all struggling with tires, Jenson in particular, which is why I was able to pass him.
"I decided to go off the circuit to make it safe for both of us. His rear tires had no traction and even on the paint I was able to stay ahead."
Button had been challenging Alonso for the lead, before his tires gave out over the last few laps.
"I had a great race out there and it is nice to be fighting at the front again," the Briton said.
Button did not want to comment on Vettel's overtaking move.
Alonso became the first driver to win three races this season and now has a 34-point lead over Mark Webber, the second Red Bull driver who was eighth.
Alonso has 154 points after 10 of 20 races, Webber has 120 and Vettel 110.
Vettel complained bitterly about Button's McLaren teammate, Lewis Hamilton, saying he was slowed on lap 35 when the Briton tried to get past cars that had already lapped him. Hamilton, in his 100th Grand Prix, had an early puncture that ruined his race before he retired on lap 59.
"I don't see the point in him trying to race us. It is a bit stupid to race the leaders," Vettel said.
Vettel said Hamilton's move probably caused him to lose second place to Button temporarily.
"That potentially lost me the position to Jenson, I pitted two or three laps after that," Vettel said. "If you are a lap down and there is no chance to win the race, you should respect it and use common sense. I didn't expect him to attack."
Michael Schumacher, the seven-time F1 champion, started from third but eventually dropped to seventh, losing a couple of places after making a late third pit stop to put on another set of soft tires. He posted the fastest lap of the race but could not gain any places and still remains winless in the third season of his comeback.
"There are better ways to finish your home race than to drop from third to seventh. But I just couldn't get more out of the car," Schumacher said.
Schumacher has not said whether he intends to continue racing and, if not, this could have been the 43-year-old German's final race at home.
Raikkonen of Finland was one of the drivers to overtake Schumacher and finished fourth in his Lotus, before Vettel's penalty moved him up to third.
Kamui Kobayashi of Japan drove his Sauber to fourth and teammate Sergio Perez of Mexico ended up sixth as the finish was reshuffled following Vettel's penalty.