Negotiators at Iran’s nuclear talks are expected to reach a provisional agreement Sunday that would curb the country’s atomic program in return for sanctions relief, diplomats told The Associated Press, a day after Iran slammed the U.S.

The two diplomats – who are at the talks and demanded anonymity because they were not authorized to discuss the negotiations publicly -- cautioned that final details of the pact were still being worked out Sunday afternoon and a formal agreement still awaits a review from the capitals of the seven nations at the talks. They said a possible announcement could come as early as Monday.

The agreement would cap nearly a decade of diplomacy, including the current round in Vienna that has run more than two weeks and blown through three deadlines.

U.S. Secretary of State John Kerry dropped warnings Sunday that the talks could go either way.

En route to Mass at Vienna's gothic St. Stephens Cathedral, Kerry said twice he was "hopeful" after a "very good meeting" Saturday with Iranian Foreign Minister Mohammad Javad Zarif, who had Muslim services Friday.

Kerry noted that "a few tough things" remain in the way of agreement but added: "We're getting to some real decisions."

A senior State Department official also said Sunday that the department will not speculate about the timing of anything during the talks and that key issues remain unresolved.

Iran and the U.S. have both threatened to walk away from the table unless the other side made concessions.

Iran’s state-run Press TV cited Ayatollah Ali Khamenei on Saturday as calling the U.S. an “excellent example of arrogance.” It reported that Khamenei told university students in Tehran to be “prepared to continue the struggle against arrogant powers.”

His comments suggest Tehran’s distrust of Washington will persist whether a deal gets done or not, and are likely to add skepticism over the outcome of the long negotiations.

Khamenei’s comments also have appeared to be a blow to U.S. hopes than agreement will lead to improved relations with the country and possible cooperation against Islamic rebels.

Iranian President Hassan Rouhani, like Kerry, indicated talks could go either way.

"We behaved so skillfully that if talks won't succeed, the world would accept that Iran is for logic and dialogue and never left the negotiating table ... and if we succeed by the grace of God, the world will know that the Iranian nation can resolve its problems through logic," his website quoted him as saying.

The supreme leader’s comments also come after it was learned Saturday that the Islamic Republic’s spies have been seeking atomic and missile technology in neighboring Germany as recently as last month.

Iran’s illegal activities have continued since talks between Iran and the P5+1 - the five permanent members of the UN Security Council as well as rotating member Germany - began with a Joint Plan of Action in 2013, according to German intelligence sources. The JPOA was intended to stop Iran’s work on a nuclear weapon until a comprehensive agreement is reached.

"You would think that with the negotiations, [Iranian] activities would drop," a German intelligence source said. "Despite the talks to end Iran’s program, Iran did not make an about-turn."

With a final agreement to restrict Iran’s nuclear program set for Monday, the intelligence data from Germany raises disturbing questions about the success of the deal.

Tehran has sought industry computers, high-speed cameras, cable fiber, and pumps for its nuclear and missile program over the last two years, according to German intelligence sources. Germany is required to report Iran’s illegal procurement activities to the UN.

The negotiations entered their 16th day Sunday. In a sign that a deal could soon be sealed, Russian news agencies reported that Russian Foreign Minister Sergey Lavrov planned to arrive in Vienna on Sunday evening. Most other foreign ministers of the six nations negotiating with Iran already are in the Austrian capital and in position to join Kerry and Zarif for any announcement of an agreement.

Diplomats familiar with the talks say most of the nuts and bolts of implementing the deal have been agreed upon. But over the past week issues that were previously on the back burner have led to new disputes. Among them is Iran's demand for a lifting of a U.N. arms embargo as part of sanctions relief -- a stance supported by Russia and China but opposed by the U.S. and some Europeans -- and its insistence that any U.N. Security Council resolution approving the deal be written in a way that effectively frames previous resolutions criticizing its nuclear activities as illegal.

On Saturday, Zarif and Kerry met again this time with European Union foreign policy chief Federica Mogherini present. Of the chief diplomats of the six countries negotiating with Iran, British Foreign Secretary Phillip Hammond and Foreign Ministers Frank-Walter Steinmeier of Germany and Laurent Fabius of France also are already in Vienna. Kerry spoke by telephone to Russian Foreign Minister Sergey Lavrov.

The scope of access to U.N. inspectors monitoring Iran's nuclear program remains a sticking point. The Americans want no restrictions. Iranian officials say unrestricted monitoring could be a cover for Western spying. Diplomats say Iran's negotiators have signaled a willingness to compromise, but hardliners in Iran remain opposed to broad U.N. inspections.

The current round was supposed to conclude on June 30, but was extended until July 7, then July 10 and now July 13. The sides had hoped to seal a deal before the end of Thursday in Washington to avoid delays in implementing their promises.

By missing that target, the U.S. and Iran now have to wait for a 60-day congressional review period during which President Barack Obama can't waive sanctions on Iran. Had they reached a deal by Thursday, the review would have been only 30 days.

Iran is unlikely to begin a substantial rollback of its nuclear program until it gets sanctions relief in return.

Fox News’ Benjamin Weinthal and The Associated Press contributed to this report.