Germany dominated the opening period and created the first clear-cut opportunity after just two minutes.
Portugal improved after the break and Boateng had to make a last-ditch sliding tackle to deny Cristiano Ronaldo when through on goal.
The game soon became subdued as Portugal camped deep inside their own half and denied the group favourites space in behind. However, with 12 minutes remaining, Germany made the breakthrough.
With Gomez, who had been frustrated for most of the game, poised to be replaced by Miroslav Klose, Sami Khedira stood up an excellent cross to the far post and the Bayern Munich target man produced a stunning header back across goal that left Patricio with no chance.
Germany, who are now joint top of Group B, face the Netherlands next in Kharkiv on Wednesday.