For weeks, Donald J. Trump has romped through Iowa and New Hampshire without breaking a sweat, muscling out rivals for the Republican nomination and soaking up adoration from crowds convinced he will be the next president of the United States.

But as Mr. Trump marches steadily toward his party’s nomination, a harsher reality awaits him.

Outside the soft bubble of Republican primaries, Mr. Trump’s campaign is confronting enduring vulnerabilities that make his nomination a considerable risk for his party. Those weaknesses were laid bare in New Hampshire on Tuesday, where independents, college-educated voters and Republicans unwilling to dismiss his legal jeopardy voted in large numbers for his rival, Nikki Haley.