WASHINGTON — At first, he vowed to “take the mantle” for closing part of the federal government. Then he blamed Democrats, saying they “now own the shutdown.” By Friday, President Trump was back to owning it again. “I’m very proud of doing what I’m doing,” he declared.

Two weeks into the showdown over a border wall, Mr. Trump is now crafting his own narrative of the confrontation that has come to consume his presidency. Rather than a failure of negotiation, the shutdown has become a test of political virility, one in which he insists he is receiving surreptitious support from unlikely quarters.

Not only are national security hawks cheering him on to defend a porous southern border, but so too are former presidents who he says have secretly confessed to him that they should have done what he is doing. Not only do federal employees accept being furloughed or forced to work without wages, they have assured him that they would give up paychecks so that he can stand strong.

Never mind how implausible such assertions might seem. The details do not matter to Mr. Trump as much as dominating the debate. After an oddly quiescent holiday season in which he complained via Twitter about being left at home alone — “poor me” — he has taken the public stage this week clearly intent on framing the conflict on his own terms.