Ferrari led all the way to the finish after both Massa and Alonso passed Vettel in his Red Bull during an exciting start at the Hockenheimring.
Massa led Alonso until a controversial call from Ferrari team boss Stefano Domenicali saw Massa hand over the lead to Alonso.
Ferrari chief engineer Rob Smedley said to Massa on the team radio, “Alonso is faster than you. Can you confirm you understand?”
With 18 laps remaining, the Brazilian gave way to his team mate.
Following the controversial move, Smedley added, “Good lad just stick with it now, sorry.”
Vettel, 23, who has still to win from starting from pole position, finished in third place ahead of McLaren drivers Britons Lewis Hamilton and Jenson Button.
Australian Mark Webber was sixth in the second Red Bull ahead of Pole Robert Kubica of Renault.
Mercedes drivers and fellow Germans Nico Rosberg and Michael Schumacher were eighth and ninth respectively followed by Russian Vitaly Petrov in the second Renault who was tenth.
Alonso’s win took him to within 34 points of drivers’ championship leader Lewis Hamilton who has 157 points.
Button is second with 143 points while Webber and Vettel are third equal with 136 points.