Some of the sanctions against Iran will be eased under an agreement reached between Iran and six world powers over the weekend. In return, Iran promises to temporarily curb part of its nuclear program.

There's widespread agreement that sanctions have worked, squeezing Iran financially and bringing its leaders to the negotiating table. Iran's economy is, by any measure, in terrible shape.

When Barbara Slavin visited Teheran in August, she was struck by the rapid deterioration of the economy. As an Iran analyst with the Atlantic Council, it was her ninth trip to the country.

"The cost of living has gone up so fast for Iranians that they are absolutely stunned, and people are simply not able to maintain the middle-class lifestyles that they used to," Slavin says.

Iran's official inflation rate is about 40 percent. By comparison, inflation in the U.S. is less than 2 percent, and many outsiders believe prices are rising even faster in Iran than the government says, especially for food.

"You see that people are not buying meat as much as they used to because it's expensive, so they're subsisting more on rice and vegetables," Slavin says. "Even vegetables and fruits are expensive in some parts of town."

Iran has struggled with inflation on and off for decades, but the massive plunge in the value of Iran's currency — the rial — over the past two years, has made inflation more pernicious. Because the rial is so weak, Iranians have to pay a lot more for imported goods. And oil, Iran's main export and the heart of its economy, is being sidelined by sanctions. Last year, the European Union joined the U.S. in an embargo on Iranian oil.

"That really had a devastating effect," says Danielle Pletka, who tracks the Middle East for the American Enterprise Institute. She says when it was just the U.S. refusing to buy, the Iranians could easily sell its oil elsewhere in the global market.

"[But] when the Europeans came on board and decided not to buy, it had a huge impact and it cut by more than half Iran's ability to sell," she says.

Those EU sanctions last year didn't just ban Iranian oil sales. They blocked Iran from the global clearing system used by banks to process financial transactions, and Danielle Pletka says that added to the pain.

"Iran is a part of the global trading environment and they live economically through the sale of natural resources," she says. "So when you go after their banks, systematically you destroy their ability to get money."

Piled on top of all this were missteps by Iranian leaders, especially former President Mahmoud Ahmadinejad. Barbara Slavin says he missed big changes in energy production that have been underway in recent years.

"He didn't realize that the United States would have access to shale oil [and] all these unconventional sources," Slavin says. "Iraq would be producing more, other countries would be producing more and that the world would not need Iranian oil as much as it used to."

Rampant inflation, a currency in freefall, oil exports slashed and a brutal squeeze on the middle class; all of this in just the past two years.

"So when you combine all of that it almost equals a perfect economic storm for Iran," says Alireza Nader, an Iran analyst with the Rand Corporation. He says the economy was the deciding factor in the election last year of a more pragmatic, less confrontational Iranian president.

"Hassan Rohani was elected with a mandate to improve the economy," he says. "He has promised he will improve the economy and decrease Iran's isolation, and to do so he must reach a negotiated settlement on the nuclear program so sanctions can be lifted."

Copyright 2016 NPR. To see more, visit http://www.npr.org/.