President Trump’s defeat in his border-wall standoff with Congress has clouded his already perilous path to a second term in 2020, undercutting Mr. Trump’s cherished image as a forceful leader and deft negotiator, and emboldening alike his Democratic challengers and Republican dissenters who hope to block his re-election.

The longest government shutdown in history inflicted severe political damage on the president, dragging down his poll numbers even among Republicans and stirring concern among party leaders about his ability to navigate the next two years of divided government. Mr. Trump, close associates acknowledge, appears without a plan for mounting a strong campaign in 2020, or for persuading the majority of Americans who view him negatively to give him another chance.

Compounding the harm to Mr. Trump on Friday was the indictment of Roger Stone, his political adviser for several decades, on charges of lying to investigators and obstructing the inquiry by the special counsel, Robert S. Mueller III, into Russian interference in the 2016 election. The indictment was taken by some Republicans as the surest sign yet that Mr. Mueller’s investigation is likely to grow more painful to Mr. Trump and his associates before it wraps up.

Mr. Trump still commands the loyalty of a passionate electoral base that has rallied to him in trying moments, and advisers believe he will have room to right himself while Democratic presidential candidates are mired in a long nomination fight. Yet they are also growing anxious that he could face a draining primary of his own next year.