Lawmakers gave the green light to the expanded mission, with a majority from the ruling centre-right coalition parties carrying the vote against strong resistance from the opposition Social Democrats and the Greens after a heated debate.
The EU's Operation Atalanta has deployed between five and 10 warships off the Somali coast since 2008 to escort humanitarian aid shipments and thwart pirate raids on commercial vessels using vital shipping lanes.
EU foreign ministers in March agreed to extend the mission until December 2014 and expand "the force's area of operations to include Somali coastal territory as well as its territorial and internal waters".
Warships or helicopters would be permitted to fire at fuel barrels, boats, trucks or other equipment stowed away on beaches.
The German mandate, which runs until May 31, 2013, limits such strikes to an area two kilometres (1.2 miles) in from the coastline and says German troops will only be permitted to go on land in cases of emergency.
Opposition parties voted against the bill, saying it amounted to irresponsible overreach for German forces.
"The possibility of operating up to two kilometres inland from the air is risky and highly dangerous," Greens parliamentary group leader Juergen Trittin said.
Germany currently has 340 military personnel participating in Atalanta.
Germany and Spain had initially voiced reservations about allowing strikes on pirate lairs but dropped their objections in March.
The sea route off Somalia is considered the most dangerous in the world. Last year alone saw around 230 pirate attacks.