JERUSALEM (AP) — Israel’s president on Monday praised Azerbaijan for playing a key role in countering Iran’s influence in the Middle East as the Muslim country’s foreign minister visited the Jewish state for the first time.

Israel believes Iran is quickly approaching the capability to build a nuclear bomb and has threatened to use military force if international diplomacy and sanctions fail to curb Tehran’s nuclear program. Iran says its program is for peaceful purposes only.

In talks Monday, President Shimon Peres told Mammadyarov that Israel considers Azerbaijan an important ally. He cited Azerbaijan’s “unique geographic location” and praised its government for taking a “clear stand” against war and terrorism.

Mammadyarov said his country, located between Russia and Iran, “is not in an easy neighborhood” and that he sees a “huge opportunity” to expand ties with Israel.

Although neither official said so, Azerbaijan could play an important role in the event of a military operation against Iranian nuclear sites, because it is next to Iran.

Israel’s relations with Azerbaijan have grown since its once-strong strategic relationship with nearby Turkey, which also borders Iran, deteriorated.

The visit came as the U.S. defense secretary, Chuck Hagel, was visiting Israel to discuss the Iran situation. The U.S. has vowed to prevent Iran from developing nuclear weapons, though it has acknowledged differences with Israel over the timeframe for taking military action.

Hagel told his Israeli counterpart on Monday that the U.S. is committed to preserving and improving the Jewish state’s military edge in the Middle East, and would permit Israel to buy various new weapons, including U.S. missiles and advanced radars for its strike aircraft. He said the U.S. would leave it to Israel to decide whether and when it needs to attack Iran.

Azerbaijan, an oil-rich former Soviet nation of 9 million people, has nurtured close relations with the United States and played an active role in Western-led counter-terrorist programs. That foreign policy has placed a strain on its ties with Iran, which hosts a sizable ethnic Azeri community.

Iran has accused Azerbaijan of allowing the Israeli spy agency Mossad to operate on its territory and use its proximity to Iran to target scientists working on Tehran’s nuclear program.

Israel says authorities foiled Iranian-sponsored attacks against Israeli targets in Azerbaijan. Azeri officials thwarted plots to explode car bombs near the Israeli Embassy in 2008 and a year before convicted 15 people in connection with an alleged Iran-linked spy network accused of passing intelligence on Western and Israeli activities.

Israel would consider a nuclear-armed Iran to be an existential threat, citing hostile Iranian rhetoric toward the Jewish state, Iran’s missile capabilities and its support for violent Middle Eastern militant groups.