President Obama on Monday gave a stern warning to Iran to cease its pursuit of nuclear weapons, during a meeting with Israeli Prime Minister Benjamin Netanyahu at the White House, citing “deepening concern” about Tehran’s progress toward nuclear capabilities.

“It is not in their interest to pursue a nuclear weapon and they should change course,” Mr. Obama said, sitting next to Mr. Netanyahu in the Oval Office.

The president said he was “not foreclosing a range of steps,” including stronger sanctions, “in ensuring Iran that we are serious.”

Mr. Netanyahu praised Mr. Obama as “a great leader” and thanked him for “leaving all options on the table” regarding Iran.

A nuclear-armed Iran, Mr. Netanyahu said, “would put us all in great peril.”

When asked whether there was a moment in time when the U.S. would stop trying to negotiate with Iran over its nuclear program, Mr. Obama said he did not “want to set an artificial deadline.”

He also bristled when asked whether Tehran would see the U.S. as weak because of Mr. Obama’s attempts to negotiate.

The highly anticipated first meeting between the two men went nearly two hours, almost double the amount of time set aside for them to talk. It was among the most high-profile, high-stakes moments of Mr. Obama’s four-month old presidency.

Mr. Netanyahu’s ascent to power has ushered in a hardline Israeli government at a moment when fears are growing about the prospect that Iran may soon be capable of producing a nuclear weapon.

Israel already has carried out a surgical air strike on what the U.S. says was a nuclear facility in Syria less than two years ago — and that was at the direction of a government far less hawkish than the one now in power. The Pandora’s Box that many around the world hope to avoid is a similar or even more severe action by Israel against Tehran, which would likely set off a chain reaction of events.

Following Mr. Obama’s private meeting with Mr. Netanyahu in the Oval Office, their top advisers joined them for an expanded discussion, before reporters were brought in at the end of the meeting. The two leaders were scheduled to share a private lunch in the Old Family Dining Room, just off the State Dining Room.