In what many observers believe are the closing hours of the two-year-long talks, one of Iran’s final demands is the lifting of a UN embargo on the sale of conventional weaponry, along with sanctions on Tehran’s development of ballistic missiles. If this is the endgame, then start counting Russian president Vladimir Putin among the winners.

While more or less maintaining ranks with the so-called P5+1 negotiating group, Putin also seems to be working toward a big Russian payday in any breakthrough with Iran—a multibillion-dollar deal to refurbish Iran’s dilapidated military.

The US and Europe have been dead set against lifting the embargo and sanctions because of Iran’s forceful politics in the Middle East, where it arms and funds the likes of Hezbollah, Hamas, and Syrian leader Bashar al-Assad. But Russia has publicly sided with Iran on the arms issue, describing it as a matter of fighting terrorism.

“We are calling for lifting the embargo as soon as possible and we will support the choices that Iran’s negotiators make,” Russian foreign minister Sergei Lavrov said in the Russian city of Ufa, where BRICS leaders are meeting. Iranian president Hasan Rouhani met today with Putin in Ufa (see photo above).

The arms issue shows how the negotiations are in a sense held hostage to the benefits to accrue to two state-run commercial behemoths—Iran’s Revolutionary Guards, who are deeply esconsed in the country’s economy and must somehow be mollified financially; and Rosoboronexport, Russia’s powerful weapons export arm, run by a former KGB special forces operative named Anatoly Isaykin.

Apart from oil, weapons are Russia’s only major export. Rosoboronexport earned $13 billion for Russia last year. After any deal, Russia intends to make good on a longstanding agreement to supply Iran with an S-300 anti-aircraft missile system. But Rosboronexport would like much, much more.

Ben Moores, a defense analyst at the research firm IHS Janes, tells Quartz that Iran’s air force is still flying aircraft procured from the US prior to the 1978 revolution. The entire fleet needs to be replaced at a cost that Moores estimates at $10 billion. He says another $4 billion in equipment is needed to refurbish the navy and army—and Russia is the likely short- and medium-term source for this equipment.

One wrinkle: Because of the long period of international sanctions, Iran has developed a robust domestic arms industry run by the Revolutionary Guards. The Guards cannot hope to compete with Russia for big-ticket air force and naval requirements. But to the degree it can, the Guards “will fight to retain domestic market share in Iran against Russian companies,” Moores said.