US Secretary of State John Kerry has said he is still confident of a nuclear deal with Iran after President Barack Obama agreed to sign legislation giving Congress the right to reject an agreement.

Mr Kerry joined his counterparts from the G7 at a meeting in northern Germany on the gathering's second day, flying in overnight after discussing Iran in Washington.

Mr Kerry said: "There was a compromise reached in Washington regarding congressional input.

"We are confident about our ability for the president to negotiate an agreement, and to do so with the ability to make the world safer."

Mr Kerry said the challenge of finishing the negotiations with Iran over the next two-and-a-half months would loom large over the G7 meeting.

Its host, German foreign minister Frank-Walter Steinmeier, said ministers would discuss the deal between the US administration and Congress, which he said would have "a certain influence" on whether a deal with Iran can be achieved by a June 30 deadline.

But Iranian President Hassan Rouhani has dismissed pressure from the US Congress over a preliminary deal on Iran's nuclear programme, saying Tehran is dealing with world powers - not American politicians.

President Rouhani spoke in the northern city of Rasht, saying that Iran is pursuing a "dignified" agreement with the six-member group - the US, Russia, China, Britain, France and Germany.

Tehran and world powers reached a framework agreement earlier this month to curb Iran's nuclear programme in return for lifting sanctions. The deal is to be finalised by June 30.

Mr Steinmeier said other topics at the G7 summit would include conflicts in the Middle East, prospects for peace talks between Israel and the Palestinians, efforts to combat the Islamic State group, the Ebola outbreak in West Africa, the impact of climate change on political stability in Africa and Asia, and the ongoing fighting in Ukraine.

"The weather in international politics is quite stormy," he said. "The conflict in eastern Ukraine is only two hours away from here."

Mr Steinmeier said the G7's top diplomats would also issue a statement on maritime security, noting that Lubeck was plagued by pirates until the Hanseatic League - an alliance of northern European trading cities - cracked down on the practice some 600 years ago.

Although Russia was ejected from what was then the G8 last year over its support for armed separatists in eastern Ukraine, Mr Steinmeier praised Moscow for what he called its "constructive attitude" in not blocking a UN Security Council resolution imposing an arms embargo on Houthi rebel leaders in Yemen.