“That became a disappointment to the Tea Party activists who thought if you’re not up there all day saying harsh things about the enemy, then you’re not doing your job,” said Dick Armey, the former House majority leader and an early Tea Party figure. “His manner was, ‘You’ve got to learn how to work with these people.’ ”

Mr. Rubio had already been working on his own immigration plan. At the outset, he favored the approach preferred by conservatives: tackling the issue in a series of smaller bills rather than one broad package.

But Senators Chuck Schumer of New York and Richard J. Durbin of Illinois, two of the Democrats in what would become known, with Mr. Rubio and five other lawmakers, as the bipartisan Gang of Eight, lobbied him hard to join their immigration group.

After seeing a Florida news report in which Mr. Rubio said young undocumented immigrants were in the country through no fault of their own, Mr. Durbin invited him to a meeting in his Senate office in May 2012. The Florida senator was wary, saying he felt many Democrats were using immigration as a political wedge issue. He said he trusted Mr. Durbin but was still noncommittal.

Mr. Durbin continued with the hard sell later that year in the Senate gym, lobbying Mr. Rubio while the Florida lawmaker pedaled a stationary bike. By the time the 113th Congress began in January 2013, Mr. Rubio was in.

The process took months, and the cost of admission to the group was politically fraught on both sides. The Republicans had to agree to support some path to citizenship for undocumented immigrants already in the country — a nonstarter for many conservatives — and the Democrats had to agree to much stronger security along the nation’s southern border. Mr. Rubio, said top aides who worked with the group, never had any problem with the path to citizenship — a provision viewed as treason by his party’s grass-roots base.

That issue is nagging at Mr. Rubio today as Senator Ted Cruz of Texas, his rival in the presidential race and an opponent of the immigration bill, has seized on it as proof that Mr. Rubio is not conservative enough on the issue. On Thursday, in an exchange between the two campaigns that quickly escalated, Mr. Cruz accused Mr. Rubio of "trying to jam this amnesty down the American people’s throats."