Rep. John Boehner (R-Ohio) was reelected as House speaker, after a group of hard-right conservatives tried and failed to deny him another term. (AP)

Republicans took full control of Congress on Tuesday, but — even on a day of happy ceremony — GOP leaders were reminded of the limits of their power, first by a veto threat from the president and then by a historic rebellion by conservatives in the House.

In the Senate, Mitch McConnell (Ky.) was sworn in as majority leader, giving Republicans control of both houses of Congress for the first time in eight years. That was the day’s most important shift, but it was anticlimactic: McConnell spoke only briefly, conscious that he was holding up the post-oath receptions.

“Tomorrow, it’s back to work,” he said. “I yield the floor.”

The day’s real drama was, instead, in the House. There, Republican control was not in doubt: After last fall’s electoral victories, the GOP has 246 of the chamber’s 435 seats, its largest majority since the 1940s.

What was in doubt was which Republican would lead.

Rep. John Boehner (R-Ohio) was reelected to serve a third term as House speaker, but hard-right conservatives rallied in opposition. (AP)

When a clerk called the roll, 24 Republicans voted for a candidate other than the incumbent speaker, John A. Boehner (Ohio). The plotters couldn’t agree on their own candidate: They voted for one another, and for two sitting senators.

In the end, their rebellion was not enough to unseat Boehner: The speaker won on the first round with 216 votes, 11 more than he needed. But it was far larger than a similar coup attempt against Boehner in 2013. In fact, it was the largest rebellion by a party against its incumbent speaker since the Civil War.

After he won, Boehner entered to a standing ovation and gave a speech calling this Congress to work together and end its gridlock. He finished with a stirring, though epically mixed, metaphor.

“So let’s stand tall and prove the skeptics wrong,” Boehner said. “May the fruits of our labors be ladders our children can use to climb to the stars.”

Still, even before the day’s ceremonies were over, there was a sign of a coming fight with President Obama. One of the new Congress’s top legislative priorities is a bill to authorize the construction of the Keystone XL oil pipeline. But Tuesday, a spokesman said Obama would veto such a bill, believing that it circumvents an established process for approving large pipeline projects.

“If this bill passes this Congress, the president wouldn’t sign it,” said White House press secretary Josh Earnest.

“This is simply another sign that President Obama is hopelessly out of touch,” Boehner said in a statement afterward.

Dissension in the ranks

The effort to depose Boehner was led by a group of hard-right conservatives and libertarians who did not think the speaker was doing enough to fight Obama over spending and executive power.

Their intent was not to beat Boehner outright. It was to humiliate him by splintering the party so that no Republican won on the first vote.

So they had a plan. What they didn’t have was a candidate.

The two who had declared themselves early on failed to inspire. Rep. Louie Gohmert (Tex.) is a former judge famous for telling a congressional witness not to cast “aspersions on my asparagus.” And Rep. Ted Yoho (Fla.) is a large-animal veterinarian known for folksy language and colorful comparisons — like equating the work of a congressman to the squeezing of a Rottweiler’s anal glands.

“Good gentlemen,” said Rep. Scott Rigell (Va.), a would-be rebel, talking about Gohmert and Yoho. But, he said, they lacked “the temperament to be speaker.”

Then another challenger emerged: Rep. Daniel Webster (Fla.), a former leader of the Florida House and Senate. In an interview Tuesday, Webster said he’d received private entreaties to run but didn’t decide to do it until the last minute.

“This happened in a 24-hour period. That’s when we really got some momentum. We had been talking about it for a while, about how I could do it. But I didn’t say ‘Yes, I’m in’ until Monday,” Webster said.

Webster handed out a mini-manifesto, called “Widgets, Principles, and Republicans.” It argued that the GOP, like any struggling company, needs to improve the way it operates, picks its leaders and sets its agenda. And it criticized the leadership for, from his perspective, too often making decisions without seeking input from those who are not close to Boehner and his inner circle.

“If a widget’s gone bad, you can go on social media and try to promote it, you can change the color, you can lower the price. It’s still the same widget. It’s still flawed,” Webster said, summing up the argument.

The election began at 12:37 p.m., when members were asked to be seated and a hush fell across the floor.

Rep. Cathy McMorris Rodgers (Wash.) nominated Boehner and highlighted his blue-collar background. “He grew up mopping floors and waiting tables at his family’s tavern,” she said. She called Boehner a “regular guy with a big job.”

Nearby sat some of the plotters: Rep. Thomas Massie (Ky.), Rep. Steve King (Iowa) and a group of other opponents. King, looking tense, had his fist under his chin. Gohmert stood alone in the center aisle.

The House was packed with people. All the aisles were full, with members’ children climbing over seats, their sneakers occasionally scuffing the brown leather seats.

The roll call began. Members were called alphabetically and stood up to shout out their votes.

In all, 408 names were called. The plotters fell short. Instead of the 30-plus GOP defectors they needed to get, there were 25 — 24 votes for other candidates and one member who simply voted “present.”

Those votes seemed to demonstrate something unintended: how splintered Boehner’s opponents were, even among themselves.

Twelve of them voted for Webster. Three voted for Gohmert, and two for Yoho. (Gohmert and Yoho voted for themselves, providing one-third and one-half, respectively, of their vote totals.) Another member cast a vote for Sen. Rand Paul (Ky.), and an Alabama congressman voted for one of his home-state senators, Jeff Sessions.

A victorious Boehner

Shortly before 2 p.m., after a brief wait while the votes were tallied, the House clerk declared Boehner the winner, leading to a wave of cheers from some Republicans and a standing ovation from nearly the entire House chamber, Democrats and Republicans.

With a dark tan from his vacation and wearing a blue tie, Boehner walked slowly as he made his way to the front, patting children of members on their shoulders and winking at a few of his friends. He said little other than “Thank you.”

After the vote, Gohmert, Yoho, King and their crew hovered in the back, their faces sullen. From the gallery, several of them were spotted checking their cellphones, eyeing the political coverage on Twitter and elsewhere, and signing off on news releases about their uprising.

Boehner was emotional as he began his remarks to the House. He said he was “feeling pretty good” until he ran into the daughters of Rep. Devin Nunes (R-Calif.), one of whom ran up and gave the speaker a kiss. “I was a mess,” Boehner said to chuckles, acknowledging his reputation for tearing up when moved by children.

Afterward, Rep. Tom Cole (R-Okla.), a Boehner confidant, said the vote should send a “message” to the anti-Boehner faction.

“I would hope they are reflecting,” Cole said. Then he put himself in the shoes of a failed plotter: “Nine out of every 10 Republicans voted against me, against my position. Maybe I’m the one that’s out of step.”

Afterward, Webster — the dark-horse candidate who got in so late — was indeed reflecting, about whether this twice-failed coup strategy could ever work.

Webster and Rep. Richard B. Nugent, both Florida Republicans, were removed from the House Rules Committee on Monday night, hours after voting against Boehner. The House speaker has long maintained expansive control over the Rules Committee and carefully selects its members because of the committee’s enormous control over the floor.

“Maybe that’s wrong, maybe that whole idea of making changes on the floor is gone. I don’t know,” he said. At the time, he was in a basement cafeteria at the Capitol, standing next to the soda machine and trying to decide what to order. Somewhere above, Boehner — the speaker once again — was happily posing for pictures with new members of Congress.

In the Senate, one key figure was missing Tuesday: Sen. Harry M. Reid (Nev.), the chamber’s top Democrat. Reid was absent from the Capitol, recuperating from an accident on a home exercise machine that left him with a concussion and broken facial bones. He was installed as minority leader anyway.

“Senator Reid is a former boxer. He’s tough. I know he’ll be back in fighting form soon enough,” McConnell said of his longtime verbal sparring partner in the Senate.

Aaron Blake, Ed O’Keefe and Paul Kane contributed to this report.