A federal judge in Miami sentenced David Rivera, a former Republican congressman from Florida and a longtime friend of Secretary of State Marco Rubio, to 10 years in prison on Friday for concealing a $50 million lobbying campaign on behalf of the Venezuelan government during the first Trump administration.

Mr. Rivera, 61, has been jailed without bond since May 1, when a jury found him guilty on all counts, including failing to register as a foreign agent and conspiracy to commit money laundering, after a seven-week trial. His co-defendant, the political consultant Esther Nuhfer, was convicted alongside him and sentenced to five years. Mr. Rivera had faced up to 60 years in prison.

He appeared stone-faced as Judge Melissa Damian told him that his friends in Miami would surely have judged him harshly had the money come from Cuba rather than its allies in Caracas. “Nobody would accept that’s ok and I don’t think this is different,” she said. “There’s no dispute this money came from the Maduro regime.” When his lawyers argued the case was about an unfiled form, she cut them off: “This is a serious offense. It’s not about not filing a piece of paper.”

Mr. Rivera spoke for 20 minutes, at times holding back tears, tracing his rise from a fatherless childhood in an immigrant neighborhood of Miami to Congress, always “fighting the good cause,” he said. Citing his age and prostate cancer, he told the judge a long term would amount to a “death sentence.”

Prosecutors said Delcy Rodríguez, then Nicolás Maduro’s foreign minister, recruited Mr. Rivera in 2017 to work his Republican connections and press the first Trump administration to soften its stance toward Venezuela and ease sanctions as the Maduro government faced accusations of human rights violations. Mr. Rivera and Ms. Nuhfer courted Mr. Rubio and Representative Pete Sessions of Texas without disclosing Mr. Rivera’s consulting contract with PDV USA, the New York-based affiliate of the state oil company PDVSA, for fear it would destroy his standing as an anti-communist. “The United States and the public were the true victims of this fraud,” Roger Cruz, an assistant U.S. attorney, said Friday.

Trial evidence included messages from an encrypted chat group Mr. Rivera set up with his conduit to the Maduro government, the Venezuelan media tycoon Raúl Gorrín, who was later charged in the United States with bribing Venezuelan officials. Members used code words: Mr. Maduro was the “bus driver,” Mr. Sessions was “Sombrero,” Ms. Rodríguez was “The Lady in Red,” Mr. Rubio was “Miss Clairol” because rubio means blond in Spanish, and the windfall payments were “La Luz,” the light.

The partners arranged meetings for Ms. Rodríguez in New York, Caracas, Washington and Dallas. Mr. Sessions tried to broker a meeting between her and the ExxonMobil chief executive and, after a secret meeting in Caracas, agreed to deliver a letter from Mr. Maduro to President Donald Trump. Prosecutors said the two concealed their work by backdating documents and creating sham agreements, including one used to justify a $3.75 million wire transfer to a South Florida company that maintained Mr. Gorrín’s luxury yacht.

The effort collapsed fast. Within six months of taking office, Mr. Trump sanctioned Mr. Maduro, called him a “dictator” and began a “maximum pressure” campaign to unseat him. Ms. Rodríguez became Venezuela’s acting president after the U.S. military ousted Mr. Maduro in January, and she has since emerged as a partner of the second Trump administration.

His lawyers said he believed the work required no registration. The three-month, $50 million contract was aimed at luring ExxonMobil back to Venezuela, commercial work generally exempt from the Foreign Agents Registration Act, and his meetings with Mr. Rubio and Mr. Sessions came after the contract ended and were aimed at replacing Mr. Maduro. “David Rivera does not deserve to die in prison because he failed to file a FARA registration,” said his lawyer, Ed Shohat. “There’s not one word in any chat, not one document, not one thing he did to help Nicolás Maduro.”

Jason A. Reding Quiñones, the U.S. attorney for the Southern District of Florida, would have none of it. “He sold his anti-communism to communists to fill his greed,” Mr. Reding Quiñones said at a news conference, calling the case a betrayal of a community “made in part of people who fled a communist regime.”

Mr. Rivera, who once shared a Tallahassee home with Mr. Rubio when both served in the Florida Legislature, kept his standing in Miami’s Cuban American establishment even after earlier scandals, among them allegations that he secretly funded a spoiler candidate in a 2012 congressional race, a case federal prosecutors dropped last year. The former president of Florida International University and the Miami-Dade County supervisor of elections packed the courtroom in support on Friday, and Mr. Sessions sent a letter calling Mr. Rivera a devoted defender of democracy. “I don’t think it’s productive for society by sending David away for a long, long time,” testified Liliana Ros, a longtime Miami Republican Party committee member.

Mr. Rivera’s lawyers plan to appeal and applied for a presidential pardon in June. He still faces a related foreign-lobbying case in Washington, and Judge Damian has yet to rule on prosecutors’ request that he forfeit $20 million in criminal proceeds. Properties he owned in Doral and the Florida Keys have already been ordered forfeited to the government.