Moscow's defence ministry said a patrol ship fired warning shots and a jet dropped bombs in the path of HMS Defender as it sailed some 12 miles (19km) off Crimea's coast.
The UK government rejected Russia's account of the incident and denied that any warning shots had been fired.
A BBC correspondent on the warship said it was harassed by Russia's military.
Aircraft could be heard overhead as BBC defence correspondent Jonathan Beale filed a report from the deck of HMS Defender in the Black Sea as it sailed to Georgia. He described hostile warnings over the radio as the warship's crew prepared for a possible confrontation.
Our correspondent, who had been invited on board the ship before the incident happened, saw more than 20 aircraft overhead and two Russian coastguard boats which at times were just 100m (328ft) away.
This is at odds with statements from both the British prime minister's office and defence ministry, which denied any confrontation.
HMS Defender was sailing from Odessa in southern Ukraine to Georgia. To get there, it passed south of the Crimea peninsula, which Russia annexed from Ukraine in 2014 in a move that has not been recognised internationally.
While Moscow claims the peninsula and its waters are Russian territory, the UK says HMS Defender was passing through Ukrainian waters in a commonly used and internationally recognised transit route.
A source told BBC diplomatic correspondent James Landale that the Defender was not there to pick a fight but to make a point - to assert its right to freedom of navigation in international waters.
Russia's defence ministry said the "dangerous actions" of the navy ship entering its waters were a "gross violation" of the UN Convention's sea laws, and called for the crew to be investigated.
A later tweet from the Russian embassy in the UK said: "HMS Defender turns HMS Provocateur and violates Russian border. Not exactly a 'routine' transit, is it?"
But a UK government spokesman played down any notion of hostilities, insisting that Russia was doing "gunnery exercises" in the Black Sea.
UK Defence Secretary Ben Wallace added: "As is routine, Russian vessels shadowed [the ship's] passage and she was made aware of training exercises in her wider vicinity."
The British ambassador was summoned to the Russian foreign ministry in Moscow, and met officials on Wednesday afternoon.
Jonathan Beale, Defence Correspondent
I am on board the warship in the Black Sea.
The crew were already at action stations as they approached the southern tip of Russian-occupied Crimea. Weapons systems on board the Royal Navy destroyer had already been loaded.
This would be a deliberate move to make a point to Russia. HMS Defender was going to sail within the 12 mile (19km) limit of Crimea's territorial waters. The captain insisted he was only seeking safe passage through an internationally recognised shipping lane.
Two Russian coastguard ships that were shadowing the Royal Navy warship, tried to force it to alter its course. At one stage, one of the Russian vessels closed in to about 100m.
Increasingly hostile warnings were issued over the radio - including one that said "if you don't change course I'll fire". We did hear some firing in the distance but they were believed to be well out of range.
As HMS Defender sailed through the shipping lane it was buzzed by Russian jets. The Captain, Vincent Owen, said the ship detected more than 20 military aircraft nearby. Commander Owen said his mission was confident but non-confrontational.
Russia said the incident happened just after midday local time (09:00 GMT) in the Black Sea near Cape Fiolent in the south of Crimea.
According to the Russian military, HMS Defender was told to change course, and when it failed to do so, a Russian border patrol ship sent several warning shots. About ten minutes later, a military jet dropped warning bombs in the path of the destroyer.
This case is reminiscent of a similar incident in November 2020, when Russia accused a US warship of travelling 2km into its waters in the Sea of Japan.
Russia's defence ministry said it had warned the USS John S McCain that it would be rammed if it continued sailing in the territorial waters, before chasing off the warship. However the US Navy said those claims were false, and that its ship had not been "expelled" from the area.
HMS Defender is a Type 45 destroyer that is part of the UK's Carrier Strike Group. It is carrying out missions in the Black Sea, according to the Royal Navy's website.
The warship was in the southern Ukrainian port of Odessa earlier this week, according to the British embassy in Ukraine. It said the UK and Ukraine had signed an agreement to jointly build warships and construct two naval bases.