JERUSALEM — The U.S. has plans in place to attack Iran if necessary to prevent it from developing nuclear weapons, Washington’s envoy to Israel said, days ahead of a crucial round of nuclear talks with Tehran.

Dan Shapiro’s message was clear — Iran should not test Washington’s resolve to act on its promise to strike if diplomacy and sanctions fail to pressure Tehran to abandon its disputed nuclear program.

Shapiro told the Israel Bar Association that the U.S. hopes it will not have to resort to military force.

“But that doesn’t mean that option is not fully available. Not just available, but it’s ready,” he said. “The necessary planning has been done to ensure that it’s ready.”

Iran has said its nuclear program is for peaceful purposes, like energy production.

The U.S. and Israel suspect that Iran is pursuing nuclear weapons, but differences have emerged in how to persuade Tehran to curb its program.

Washington says diplomacy and economic sanctions must be given a chance to run their course, and is taking the lead in the ongoing talks between six global powers and Iran.

Israel, while saying it would prefer a diplomatic solution, has expressed skepticism about these talks and says time is running out for military action to be effective.

President Barack Obama has assured Israel that the U.S. is prepared to take military action if necessary, and it is standard procedure for armies to draw up plans for a broad range of possible scenarios.

Shapiro’s comments were the most explicit sign yet that preparations have been stepped up.

“We do believe there is time. Some time, not an unlimited amount of time,” Shapiro said. “But at a certain point, we may have to make a judgment that the diplomacy will not work.”

The U.S. envoy spoke Tuesday. The Associated Press obtained a recording of his remarks Thursday.

The five permanent members of the U.N. Security Council and Germany are gearing up to for a May 23 meeting with Iran in Baghdad.

Shortly after the meeting, the U.N. atomic agency is to release its latest report card on Iran’s nuclear efforts.

In Tehran Thursday, top nuclear negotiator Saeed Jalili warned against Western pressure at next week’s talks. “Cooperation is what we can talk about in Baghdad,” Jalili said in a broadcast on Iranian state TV.