WASHINGTON — The Oval Office meeting this past March began, as so many had, with President Trump fuming about migrants. But this time he had a solution. As White House advisers listened astonished, he ordered them to shut down the entire 2,000-mile border with Mexico — by noon the next day.

The advisers feared the president’s edict would trap American tourists in Mexico, strand children at schools on both sides of the border and create an economic meltdown in two countries. Yet they also knew how much the president’s zeal to stop immigration had sent him lurching for solutions, one more extreme than the next.

[Update: Trump denies considering a border moat.]

Privately, the president had often talked about fortifying a border wall with a water-filled trench, stocked with snakes or alligators, prompting aides to seek a cost estimate. He wanted the wall electrified, with spikes on top that could pierce human flesh. After publicly suggesting that soldiers shoot migrants if they threw rocks, the president backed off when his staff told him that was illegal. But later in a meeting, aides recalled, he suggested that they shoot migrants in the legs to slow them down. That’s not allowed either, they told him.

“The president was frustrated and I think he took that moment to hit the reset button,” said Thomas D. Homan, who had served as Mr. Trump’s acting director of Immigration and Customs Enforcement, recalling that week in March. “The president wanted it to be fixed quickly.”