NEW YORK — Joe Biden stood before a row of American flags on Tuesday and did something that hasn't always been his first instinct: He warned against American military engagement.

Biden, blasting President Trump as "dangerously incompetent" for his handling of the crisis with Iran, said Trump's "impulsive decision" to order the killing of a top military official from that country put the United States at risk of greater international conflict.

“A president who says he wants to end endless war in the Middle East is bringing us dangerously close to starting a new one,” said the former vice president, who is among the top contenders battling for the Democratic presidential nomination. He added, “This outcome of strategic setbacks, heightened threats, chants of ‘Death to America’ once more echoing across the Middle East, Iran and its allies vowing revenge — this was avoidable.”

Biden’s comments were striking for someone who has spent much of his political career with a reputation as a foreign policy expert who has often embraced American use of power in the world. As a senator, he voted in 2002 to authorize the use of force in Iraq — a vote that has become a point of contention in the Democratic race as Sen. Bernie Sanders (I-Vt.) presents himself as the true antiwar candidate in tune with rising public skepticism of drawn-out military intervention.

Sanders has been among the most aggressive critics of Trump’s Iran strike, declaring the killing an “assassination” and referring to it as “a dangerous escalation that brings us closer to another disastrous war in the Middle East.” He has also seized on the moment to step up his criticism of Biden’s Iraq vote, needling him Monday night on CNN for his role in the “most dangerous foreign policy blunder in the modern history of this country.”

Biden’s toughened rhetoric on Trump and Iran on Tuesday seemed designed to present Biden with a more nuanced position — more sharply critical of Trump’s decision than his previous comments but not as black-and-white as Sanders’s stance.

Biden stopped short of saying that the killing of Iran’s Qasem Soleimani was the wrong decision, saying that he was deeply skeptical but holding out the possibility that he would agree with Trump’s call if given more information. Instead, the former vice president called on Trump to explain his decision to the American public, saying, “If there was an imminent threat that required this extraordinary action, we’re owed an explanation and the facts to back it up.”

Biden referred to this as “possibly the most dangerous time in recent American history” and accused Trump of creating the conditions.

“Trump’s impulsive decision may well do more to strengthen Iran’s position in the region than any of Soleimani’s plots would have ever accomplished,” he said.

Biden’s remarks Tuesday offered some contrasts in what has emerged as a burgeoning foreign policy debate between him and Sanders.

Biden said the current turmoil was triggered by Trump’s decision to withdraw from the Iran nuclear deal, which was crafted under the Obama administration and provided sanctions relief in return for Iran curbing its nuclear ambitions. Sanders has said the turmoil is rooted much earlier — in the U.S. decision to invade Iraq.

Sanders on Friday introduced legislation that would block funding for any military actions against Iran without congressional authorization. A Biden aide would not say whether Biden supported that measure but noted that he did back a war-powers resolution sponsored by House Speaker Nancy Pelosi (D-Calif.). That legislation would mandate military hostilities to cease within 30 days if no congressional action is taken.

Foreign policy observers said that Sanders and Biden are still promoting distinctly different worldviews — but that, in the heat of the primary, Biden appeared to be trying to showcase his ability to appeal to those wary of U.S. involvement abroad.

While some see him as a hawk, Biden has also held dovish positions in the past, opposing the Persian Gulf War under President George H.W. Bush and counseling his boss, President Barack Obama, against a surge of troops in Afghanistan.

“Biden is a believer in American leadership and engagement, no question. He comes from that school,” said Aaron David Miller, a senior fellow at the Carnegie Endowment for International Peace and a former State Department Middle East analyst. “But these remarks also suggest he’s trying to appeal to the noninterventionists in the party, too, by suggesting we need to be smarter and more disciplined in how and when America engages.”

“It’s finding a balance,” Miller added. “It’s the Goldilocks approach. It’s not too hot, not too cold.”

Michael O’Hanlon, a senior fellow at the Brookings Institution, said Sanders remains to the left of Biden when it comes to the broader debate about the United States’ role in the world.

“I don’t really sense Biden is moving toward Sanders — he sees an opportunity to hit hard against Trump,” O’Hanlon said. “I still think Sanders leans more toward pacifism, Biden more toward engagement.”

Biden delivered his remarks in a banquet hall on a pier in Chelsea, standing in front of a large blue curtain and four American flags, an attempt to re-create the tapestry of a presidential speech in front of dozens of journalists and a handful of advisers.

He spoke after a morning fundraiser in New York in which he also talked extensively about the situation in Iran.

Trump “has to understand that he cannot take this nation to war with Iran without the informed consent of the American people,” Biden said during a morning fundraiser on the 37th floor of a Manhattan office building that houses the Skadden law firm.

He said he arrived late because he was on a phone call with his national security team.

“The idea that he can take us into a conflict potentially with a country of 80 million people in the Middle East, without the consent of American people — and doing it by tweet — is just preposterous,” he added.

In his speech, Biden also accused Trump of getting closer to an overreach of presidential power.

“The American people do not want, and our Constitution will not abide, a president who rules by fiat and demands obedience,” Biden said.

“We need to restore the balance of powers between the branches of government,” he added.

Biden has in the past been supportive of limited military action that did not require congressional approval. He sponsored legislation in 1995 that would authorize the president to use force in the absence of congressional approval to “forestall an imminent act of international terrorism directed at US citizens or nationals or to retaliate against the perpetrators of such an act.”

His presidential campaign website in 2008 said, specifically about Iran, that the Founding Fathers were clear that a president needs congressional approval “to initiate war, except to repel an imminent attack on the United States or its citizens.”

It also noted: “If the President takes us to war with Iran without Congressional approval, I will call for his impeachment. I do not say this lightly or to be provocative. I am dead serious.”