A Ukrainian strike last weekend on an Iranian cargo ship in the Caspian Sea has underscored the links between the wars that the two countries are fighting, raising tensions between them as well as the risk of more direct confrontation.

Ukraine said the ship was carrying military equipment between Iran and Russia. Iranian officials said it was a commercial vessel, and it accused Ukraine of killing a sailor in the attack.

Iranian officials threatened retaliation in a series of statements and comments to the news media. Ukraine’s foreign minister, Andrii Sybiha, snapped back, telling Iran it had “no standing to pretend to be a victim” given its military support for Russia in its war with Ukraine.

Here’s a look at how Iran and Ukraine became adversaries through two separate wars — and why their indirect conflict now risks becoming a direct one.

Russia hit Ukraine with Iranian drones.

Iran and Russia have had a close military relationship for decades. The most visible recent example of this is the long-range attack drones that Tehran has supplied to Moscow.

Russia launched swarms of the drones across Ukraine within months of its 2022 invasion, to deadly effect. The United States has accused Iran of supplying Russia with short-range ballistic missiles as well. And Ukraine said Iran had sent trainers to help the Russian military use drone systems, a claim that Iran denied.