President Obama said Friday he spoke with new Iran President Hasan Rouhani by phone, the first top-level U.S.-Iranian contact in more than three decades.

Obama said he and Rouhani discussed the standoff over Iran's nuclear program, and agreed to direct their teams to negotiate an agreement in which Iran would forswear the ability to develop nuclear weapons.

"While there will surely be important obstacles to moving forward and success is by no means guaranteed, I believe we can reach a comprehensive solution," Obama said.

The United States has said it will not allow Iran to develop the means to make nuclear weapons; Iran said its nuclear program is designed for peaceful energy programs.

Rouhani confirmed the phone conversations in a series of Twitter message, saying in one that "in regards to nuclear issue, with political will, there is a way to rapidly solve the matter."

In another tweet, Rouhani told Obama: "I express my gratitude for your hospitality and your phone call. Have a good day Mr President."

Iran will be a major topic Monday when Obama meets with Israeli Prime Minister Benjamin Netanyahu, who has raised questions about Iran's sincerity.

The United States broke relations with Iran after Iranian revolutionaries seized American embassy hostages in 1979.

In addition to the announcement about Iran, Obama again said that Republicans will be responsible if the government shuts down or defaults on its debts in the weeks ahead.

Saying he was speaking to Republicans, Obama said: "I'd encourage you to think about who you're hurting."

Obama spoke hours after the Democratic-run Senate passed a temporary spending plan that includes the president's new health care plan -- a provision members of the Republican-run House say they will not accept.

If the parties cannot agree on a spending plan by the start of the fiscal year on Tuesday, many parts of the government will shut down.

The health care dispute could also affect efforts to increase the debt ceiling, which gives the government authority to borrow money to repay its debts. Some Republicans say they will oppose raising the debt ceiling unless health care is defunded.

In the White House briefing room, Obama said the health care plan will move forward, and he will not negotiate on the need to raise the debt limit.

"Nobody gets to threaten the full faith and credit of the United States," Obama said.

Obama said a default would do more damage to the economy than a shutdown.

In addition to the budget and Iran, Obama echoed comments he made earlier in the day, saying a proposed chemical weapons agreement with Syria on Friday could be a huge victory for the world community.