ORLANDO — Former New Mexico governor Gary Johnson won the Libertarian Party’s presidential nomination on Sunday, fending off five rivals from different factions on two closely fought ballots and securing more than 55.8 percent of the total vote.

“I will work as hard as I can to represent everyone in this room,” Johnson said after his victory. “After this convention, people will be looking to us to describe what it means to be a Libertarian. And I realize it will be up to me to tell them.”

But Johnson’s near-miss on the first ballot kicked off an afternoon of protests and delegate glad-handing, with the vice presidential race to be decided later. Johnson had run a careful campaign with an eye on the general election, picking former Massachusetts governor Bill Weld — like him, a Republican who switched parties — as his running mate. In Saturday night’s debate, Johnson, alone among the top-five contenders, said that he would have signed the 1964 Civil Rights Act and that he thought people should be licensed to drive cars. He was loudly booed for both positions.

“I liked it,” Johnson said in an interview before Sunday’s vote. “Let’s draw attention to the only candidate onstage saying that he would sign the Civil Rights Act, let’s draw attention to the only candidate onstage who’s in favor of driver’s licenses. I don’t know about you guys, but I think that’s a great distinction between myself and the rest of them.”

Those positions were tough to swallow for some of the party’s self-identified radicals. They’d spent the campaign season — including more than a dozen debates — labeling Johnson a “Republican-lite” candidate who could not expand on the 1 percent of the vote he had won as the 2012 nominee. Johnson was silent when the first ballot showed him just six votes short of a majority.

Johnson’s rivals, especially Libertarian activist Austin Petersen and software engineer John McAfee, saw an opportunity to drag out the process. They briefly huddled on the convention floor and worked delegates, as Johnson had unfruitful conversations with critics and then walked outside for an interview with MSNBC.

“It’s not unique to the Libertarian Party that we have factions,” Johnson said. “When Republicans and Democrats get to this stage of the process, they’ve already gone through their primaries. You don’t hear much of a contrast. In the case of Libertarians — not so much.”

Outside the convention floor, Johnson was followed by supporters — his own and hold-outs from a “Never Johnson” faction.

The scrum quieted down for Johnson to do the interview. But when it ended, Petersen gave chase and pulled Johnson aside — in full view of reporters.

“Do you want to unite the party?” Petersen asked.

“This is not the place, Austin,” said Johnson, referring to the media attention.

“Why did you pick Bill Weld?” Petersen asked.

Johnson shook his head and walked away, as Petersen denounced Weld as a “horrible statist” and argued with a Johnson supporter who said that, at 35, Petersen was too young to represent the party.

“Tell that to Marquis de Lafayette,” Petersen said. “He was 18.”

Meanwhile, Johnson was securing the votes of Libertarian delegates who had cast sympathy ballots for lesser-known candidates. Johnson gained 60 votes on the second ballot, while Marc Allan Feldman, a well-liked physician who just that morning had helped people injured by a hit-and-run driver, lost 40 votes between ballots.

Johnson’s victory began the race for vice president, which promised drama of its own. Weld, who had made a fitful Libertarian run for governor of New York in 2006, was not otherwise tied to the party. As he did interviews and met delegates, he made up ground but acknowledged that he did not always align with the party base. After the first presidential ballot, Weld said in a short interview that he had finally read the LP's platform and disagreed with part of it.

“It’s pretty good,” he said. “They want to eliminate the income tax; that wouldn’t bring in enough revenue. I’m for a flat tax.”

What was unclear, as the vice presidential fight began, was who could overtake Weld. The candidates for vice president were a mixture of obscure activists. McAfee ruled out running for the second spot on the ticket; Petersen said he would do it only if Johnson fired his campaign staff.

In his victory speech, Johnson beseeched the delegates to look past any of their ideological qualms with Weld to consider the breakthrough the party could win if it nominated two former Republicans. Weld, he said, had done 25 major media interviews since agreeing to run. That was 25 more interviews than Jim Gray, a judge who became Johnson’s 2012 running mate, ever did.

“I realize it’s up to you,” Johnson said. “If it’s not Bill Weld, I don’t think we have the opportunity to be elected president of the United States.”