The move marks a significant policy change that came a day after US President Joe Biden gave Kyiv the green light to strike back with American weapons at Russian military assets targeting the country's second-largest city of Kharkiv.
A German government statement noted that, in recent weeks, Russia had prepared, co-ordinated and carried out attacks on Ukraine's northeastern Kharkiv region in particular from areas just over the border in Russia.
"Together we are convinced that Ukraine has the right under international law to defend itself against these attacks," the statement said on Friday.
"For this, it can also use the weapons delivered for that purpose in accordance with its international legal commitments, including the ones delivered by us," it said, without elaborating on what Berlin called confidential agreements with Kyiv.
A Russian onslaught in the northeastern Kharkiv region, including a Russian aerial bomb attack on a large construction supplies store that killed 18 people on May 25, has forced the evacuation of thousands of people and has stretched Ukraine's depleted forces.
That appears to have prompted the change in policy among Western leaders.
The Kremlin's bigger and better-equipped army is exploiting Ukrainian shortages in troops and ammunition after a lengthy delay in US military aid.
Western Europe's inadequate military production has also slowed crucial deliveries of military aid to Ukraine.
Russia launched five missiles at Kharkiv overnight, one of them hitting a residential building. (AP PHOTO)
Biden's decision allows for US-supplied weapons to be used for "counter-fire purposes in the Kharkiv region so Ukraine can hit back against Russian forces that are attacking them or preparing to attack them", a Washington official told the Associated Press.
But the official, who requested anonymity to discuss the subject, stressed the US policy calling on Ukraine not to use American-provided ATACMS or long-range missiles and other munitions to strike offensively inside Russia had not changed.
The German announcement came hours after Russian ballistic missiles slammed into an apartment block in Kharkiv and killed at least four people in a night-time attack.
Russia launched five S-300/S-400 ballistic missiles at Kharkiv overnight, Ukraine's air force said.
One of them struck a residential building and was followed by another missile 25 minutes later that hit first responders, according to regional Governor Oleh Syniehubov.
At least 25 people were injured, he said.
Ukrainian officials have previously accused Russia of targeting rescue workers by hitting residential buildings with two consecutive missiles - the first one to draw emergency crews to the scene and the second one to wound or kill them.
Apart from Kharkiv, Moscow's troops are pressing in the Donetsk region further south and are assembling a force for an expected attack in the Sumy region further north, according to Ukrainian officials.
The restrictions on the use of Western weapons have frustrated Ukrainian officials as the military has been unable to order hits on Russian troops massing across the border - Kharkiv city is only 20km from Russia - or Russian bases used to launch missile attacks.
The question of whether to allow Ukraine to hit targets on Russian soil with Western-supplied weaponry has been a delicate issue since Moscow launched its invasion on February 24, 2022.
Western leaders hesitated to take the step because it ran the risk of provoking Russian President Vladimir Putin, who has repeatedly warned that the West's direct involvement could put the world on a path to nuclear conflict.
But as Russia has recently gained the battlefield initiative in parts of the 1000km front line, some Western leaders are pushing to allow Kyiv to strike military bases inside Russia with sophisticated long-range weapons provided by its Western partners.
However, NATO chief Jens Stoltenberg on Friday dismissed warnings by Russian Putin that allowing Kyiv to use Western weapons for strikes inside Russian territory might lead to an escalation.
Speaking on the sidelines of a NATO foreign ministers' meeting in Prague on Friday, Stoltenberg said the alliance had heard such warnings many times before
AP and Reuters