MODESTO, Calif. — This should have been a victory lap for Speaker Paul D. Ryan. Summoned by his party to heal its fractious majority in the House, Mr. Ryan grudgingly agreed to lead. Asked by House members to help them win re-election, he raised money by the millions and traveled thousands of miles to campaign at their side.

But with elections not even two weeks away, Mr. Ryan finds that his feuding with Donald J. Trump, the Republican presidential nominee, has threatened not only the largest Republican majority in the House since the 1930s, but also his speakership itself.

For Mr. Ryan, the arc of the past four years — from vice-presidential pick of Mitt Romney to object of Mr. Trump’s scorn — represents perhaps the best measure of the chaos the Trump candidacy has wrought within the party.

In the weeks since Mr. Ryan said that he would no longer defend Mr. Trump or campaign for him, he has heard some mutinous rumblings among his members — a smattering of dissent that may mean little unless Democrats can claim about 20 seats in this election, at the upper end of analysts’ predictions.