It was a stunning setback for the president and for Mr. Kushner, who had told colleagues that public opinion would move to their side and that Speaker Nancy Pelosi would emerge as the one who looked unreasonable and intransigent.

Mr. Kushner had advised the president against declaring a national emergency, which would enable him to get funding for his wall without approval from Congress. Instead, he ultimately pushed Mr. Trump toward the announcement he made on Friday, supporting it as a way to buy more time to reach a deal.

Mr. Trump, White House aides said, has been frustrated at everyone around him for not delivering a deal he can accept. And he has become wary of his son-in-law’s advice on this issue, the aides said.

This account is based on interviews with more than a dozen congressional officials, White House aides and people involved in the immigration debate.

On Capitol Hill, aides said, Mr. Kushner had positioned himself as the person who could sell the president on a compromise, casting himself as a facilitator who did not lobby for details of any proposal but simply wanted to find a solution that both sides could claim as a victory.

Mr. Kushner has told Mr. Trump that he should spend the next three weeks trying to achieve a broader immigration package. That challenge has eluded both parties for years, but Mr. Kushner has suggested to colleagues that it is worth trying for, according to West Wing aides.