Bastian Schweinsteiger sidefooted in the first and created the second with a free-kick for Miroslav Klose.
Nuno Gomes finished from close range to give Portugal hope but they failed to defend another Schweinsteiger free-kick and Michael Ballack headed their third.
Portugal substitute Helder Postiga pulled one back in the dying stages but there was to be no grandstand finish.