By GEORGE JAHN and MATTHEW LEE

VIENNA (AP) _ After 18 days of intense and often fractious negotiation, diplomats Tuesday declared that world powers and Iran had struck a landmark deal to curb Iran’s nuclear program in exchange for billions of dollars in relief from international sanctions _ an agreement designed to avert the threat of a nuclear-armed Iran and another U.S. military intervention in the Muslim world.

The accord will keep Iran from producing enough material for a nuclear weapon for at least 10 years and impose new provisions for inspections of Iranian facilities, including military sites.

The European Union, which has shepherded the talks, announced a final session between the foreign ministers of Iran, the United States, Britain, China, France, Germany and Russia for 10:30 a.m. local time in Vienna (4:30 a.m. ET). An announcement of the accord was to be made afterward at a news conference with EU foreign policy chief Frederica Mogherini and Iranian Foreign Minister Mohammad Javad Zarif, the diplomats said.

The diplomats spoke on condition of anonymity because they were not authorized to discuss the deal before it is officially announced.

The so-called Joint Comprehensive Plan of Action was reached after more than two weeks of furious diplomacy, during which negotiators blew through three self-imposed deadlines. Zarif and U.S. Secretary of State John Kerry, who conducted most of the negotiations, both threatened to walk away while trading accusations of intransigence.

The breakthrough came after several key compromises.

Diplomats said Iran agreed to the continuation of a U.N. arms embargo on the country for up to five more years, though it could end earlier if the International Atomic Energy Agency definitively clears Iran of any current work on nuclear weapons. A similar condition was put on U.N. restrictions on the transfer of ballistic missile technology to Tehran, which could last for up to eight more years.

Washington had sought to maintain the ban on Iran importing and exporting weapons, concerned that an Islamic Republic flush with cash from the nuclear deal would expand its military assistance for Syrian President Bashar Assad’s government, Yemen’s Houthi rebels, the Lebanese militant group Hezbollah and other forces opposing America’s Mideast allies such as Saudi Arabia and Israel.

Iranian leaders insisted the embargo had to end as their forces combat regional scourges such as the Islamic State. And they got some support from China and particularly Russia, which wants to expand military cooperation and arms sales to Tehran, including the long-delayed transfer of S-300 advanced air defense systems _ a move long opposed by the United States.

Another significant agreement will allow U.N. inspectors to press for visits to Iranian military sites as part of their monitoring duties, something the country’s supreme leader, Ayatollah Ali Khamenei, had long vowed to oppose. However, access isn’t guaranteed and could be delayed, a condition that critics of the deal are sure to seize on as possibly giving Tehran time to cover up any illicit activity.

Under the deal, Tehran would have the right to challenge the U.N request and an arbitration board composed of Iran and the six world powers would then decide on the issue. The IAEA also wants the access to complete its long-stymied investigation of past weapons work by Iran, and the U.S. says Iranian cooperation is needed for all economic sanctions to be lifted. IAEA chief Yukiya Amano said Tuesday his agency and Iran had signed a “roadmap” to resolve outstanding concerns.

The overall nuclear deal comes after nearly a decade of international, intercontinental diplomacy that until recently was defined by failure. Breaks in the talks sometimes lasted for months, and Iran’s nascent nuclear program expanded into one that Western intelligence agencies saw as only a couple of months away from weapons capacity. The U.S. and Israel both threatened possible military responses.

The United States joined the negotiations in 2008, and U.S. and Iranian officials met together secretly four years later in Oman to see if diplomatic progress was possible. But the process remained essentially stalemated until summer 2013, when Hassan Rouhani was elected president and declared his country ready for serious compromise.

More secret U.S.-Iranian discussions followed, culminating in a face-to-face meeting between Secretary of State John Kerry and Iranian Foreign Minister Mohammad Javad Zarif at the United Nations in September 2013 and a telephone conversation between Rouhani and President Barack Obama. That conversation marked the two countries’ highest diplomatic exchange since Iran’s 1979 Islamic Revolution and the ensuing hostage crisis at the American embassy in Tehran.

Kerry and Zarif took the lead in the negotiations. Two months later, in Geneva, Iran and the six powers announced an interim agreement that temporarily curbed Tehran’s nuclear program and unfroze some Iranian assets while setting the stage for Tuesday’s comprehensive accord.

It took time to get the final deal, however. The talks missed deadlines for the pact in July 2014 and November 2014, leading to long extensions. Finally, in early April, negotiators reached framework deal in Lausanne, Switzerland, setting up the last push for the historic agreement.

Protracted negotiations still lie ahead to put the agreement into practice and deep suspicion reigns on all sides about violations that could unravel the accord. And spoilers abound.

In the United States, Congress has a 60-day review period during which Obama cannot make good on any concessions to the Iranians. U.S. lawmakers could hold a vote of disapproval and take further action.

Iranian hardliners oppose dismantling a nuclear program the country has spent hundreds of billions of dollars developing. Khamenei, while supportive of his negotiators thus far, has issued a series of defiant red lines that may be impossible to reconcile in a deal with the West.

And further afield, Israel will strongly oppose the outcome. It sees the acceptance of extensive Iranian nuclear infrastructure and continued nuclear activity as a mortal threat, and has warned that it could take military action on its own, if necessary.

The deal is a “bad mistake of historic proportions,” Israeli Prime Minister Benjamin Netanyahu said Tuesday, adding that it would enable Iran to “continue to pursue its aggression and terror in the region.”

Sunni Arab rivals of Shiite Iran are none too happy, either, with Saudi Arabia in particularly issuing veiled threats to develop its own nuclear program.