James Cleverly made the comments after speaking on deterring Russian President Vladimir Putin’s aggression by “strengthening our collective security”, and made the case for Sweden to swiftly join Nato.
Mr Cleverly was asked about Tuesday’s drone attack on Moscow and whether Ukraine had the right to attack Russian territory.
“I don’t have details, and I am not going to speculate about the nature of the drone attacks in Moscow. So what I’m about to say are more general points, rather than on that specific incident,” he said.
“Ukraine does have the legitimate right to defend itself.
“It has the legitimate right to do so within its own borders, of course, but it does also have the right to project force beyond its borders to undermine Russia’s ability to project force into Ukraine itself.
“So legitimate military targets beyond its own border are part of Ukraine’s self-defence. And we should recognise that.
“That is not to say that I have any particular assessment over the attacks in Moscow, but more broadly, military targets beyond its own border are internationally recognised as being legitimate as part of a nation’s self-defence.”
Mr Cleverly is on a two-stop trip to Europe to meet the country’s military partners.
He met members of the government and UK military personnel during his stop in Estonia on Tuesday.
On Wednesday, he will fly to Norway for a meeting of Nato foreign ministers, with the war in Ukraine set to top an agenda that will also include a discussion of Sweden's accession before a major conference in Vilnius, Lithuania, in July.
Objections from Turkey and Hungary have so far slowed the process for Swedish membership.
Speaking ahead of the trip, Mr Cleverly said: “In Estonia, across land, sea and air, British personnel are on the front line protecting Europe’s security and deterring Russia’s cruel and catastrophic aggression.
“As Nato allies, we are stronger than ever before – unified against hostility and in defence of democracy and freedom.
“Not only is our military leading the way, our diplomats are working across the globe to galvanise our partners and strengthen international efforts to ensure Putin faces the consequences of his barbaric actions.”
During Mr Cleverly’s stop in Estonia, his first official trip to the country, he will visit the Royal Navy's HMS Albion in the Baltic Sea and see first-hand how British forces personnel are leading Nato’s land and air missions.
At Amari airbase, the Foreign Secretary will watch RAF Typhoons taking to the skies as the current lead nation for Baltic air policing out of Estonia, and see British Army Apache and Wildcat helicopters supporting multinational exercises.
In Estonia, he will also speak with people working in the country's technology sector to promote economic ties with the UK, and visit a school for children of Ukrainian refugees.