The scene in the Capitol on Tuesday was teeming with ceremony and tradition. Vice President Joseph R. Biden Jr., in his formal role as president of the Senate, was on hand to swear in the new senators. He blended a conventional “Welcome to the Senate” with a number of humorous personal asides as they stepped up one by one to the well of the Senate chamber to shake his hand.

The atmosphere was heavier in the House. The vote on Mr. Boehner’s fate dragged on for more than an hour as the clerk read aloud the names of all House members.

Image Tracking the votes for House speaker. Credit... Jonathan Ernst/Reuters

A last-minute move by Representative Daniel Webster, Republican of Florida, to challenge Mr. Boehner hurt the speaker, most likely costing him more votes than he would have lost otherwise. Initially only two Republican congressmen rose up against Mr. Boehner, both of whom are considered on the fringe of the party and dismissed by leadership as gadflies: Louie Gohmert of Texas and Ted Yoho of Florida. But the entry of Mr. Webster, a more pragmatic Republican who has a cordial relationship with Mr. Boehner, came as somewhat of a surprise.

Mr. Boehner moved swiftly on Tuesday to punish Mr. Webster for his disloyalty, deciding to strip him of his seat on the powerful Rules Committee, a top Republican said.

The opposition to Mr. Boehner reflected the palpable resentment the Republican Party’s base harbors toward its leadership in Washington. Almost since he first took up the speaker’s gavel in 2011, Mr. Boehner has faced calls for his ouster from the far right. Tea Party groups routinely raise money from email solicitations asking their supporters to help “Fire the Speaker.”

Tea Party conservatives felt betrayed anew late last month after Mr. Boehner ignored their pleas to push the government toward another shutdown by denying funding in the federal spending plan to enforce the president’s new immigration orders.