Media playback is not supported on this device
The Spaniard became the only man to win three times so far this season.
He drove a controlled race and stayed just far enough ahead of his pursuers to maintain the lead.
Great strategy calls from the team to keep me ahead through the pit stops. I knew it would be a long race to the end
Button climbed up from sixth on the grid to pass Vettel at the second pit stops but was re-passed with two laps to go.
However, the Englishman was promoted to second place after race stewards gave Vettel a 20-second penalty for his overtake of Button on the penultimate lap.
Lewis Hamilton retired with gearbox damage after running well down the field following an early puncture. But he will not incur any penalty for a gearbox change because of his retirement.
The result extends Alonso's championship lead to 34 points ahead of Red Bull's Mark Webber who had a low-key race to eighth place, never showing any real pace.
Alonso said: "It was tough, not an easy race. Maybe we were not the quickest in dry conditions but we were competitive and it was enough to maintain the lead.
"Great strategy calls from the team to keep me ahead through the pit stops. I knew it would be a long race to the end, with Jenson putting pressure.
"But the car was feeling good on top speed and traction and that was enough to keep the lead into Turn 6, and after that overtaking is not so easy."
Media playback is not supported on this device
The only consolation for Hamilton on the occasion of his 100th grand prix was that the McLaren showed encouraging pace following a major performance upgrade.
At one stage, Hamilton unlapped himself on Vettel - although not Alonso - as he attempted vainly to recover from his early set-back. A move which angered the double world champion.
Alonso was never very far in front but was always able to stay just far enough ahead of first Vettel and then Button to ensure they could not use their DRS overtaking aids to pass him into the hairpin at Turn 6.
It led to a tense grand prix in which the identity of the winner was always in doubt until Alonso took the chequered flag.
The Ferrari made a lightning start from pole position and although Vettel quickly closed up the initial gap Alonso had built on the first lap, the Spaniard was able to pull clear before their first pit stops to ensure he held the lead into the second stint.
Meanwhile, Button was fighting past Hulkenberg and then Schumacher, to move quietly into third place.
Vettel emerged from his first pit stop five seconds ahead of Button but the McLaren closed remorselessly on the Red Bull and passed the German by making his second stop a lap earlier.
Vettel emerged from the pits to find Button on his outside on the run to Turn 2, and the McLaren easily took the position.
Button was rarely more than a second behind Alonso from then until the end of the race but the Ferrari driver was always in control and in the closing laps he stretched away as Button began to lose grip in his rear tyres.
Rather than try to take the lead, Button had to spend the closing laps fighting off a late challenge from Vettel, who passed him at the Turn 6 hairpin on the penultimate lap.
Vettel said: "The pace was there but it was extremely difficult when I was close to Fernando and Jenson we seemed to lose a lot and not be able to stay close enough to try to something under braking.
"I am not entirely happy, it could have been a bit better if it was clean air most of the race but that was not the case. Second place was the best we could get today and I am happy with that."
Button said: "It was a close race and I couldn't quite get Fernando at the end.
"When you are in the middle of three you really have to fight and I was pushing a little bit more in the early part of the stint, whereas when you're in front you can coast a bit in the bits where you don't need to push.
"It was close but Fernando knows as we all do where to use Kers to keep someone behind you. I ran out of steam at the end of the straight and the gap was a little bit too big to get back.
"But it was a fun race and it's nice to be on the podium again. I've had my feeling back the last two races but the pace hasn't been there [in the car], but today it was. We're there or thereabouts at the front, still a little way to go."
Raikkonen provided some exciting racing as he moved up from 10th on the grid.
On the way, Raikkonen engaged in top-class racing with Mercedes driver Michael Schumacher and the Force Indias of Nico Hulkenberg and Paul di Resta.
Schumacher finished seventh behind Sauber drivers Kamui Kobayashi and Sergio Perez. Hulkenberg and Di Resta took the final points positions in ninth and 10th.
Ferrari's Fernando Alonso beat Red Bull's Sebastian Vettel and McLaren's Jenson Button in a close fight to win the German Grand Prix.