SAN FRANCISCO — Closing a dark chapter in California politics and capping the downfall of a prominent Bay Area legislator, former state Sen. Leland Yee on Wednesday pleaded guilty to a federal racketeering charge that is expected to land him in a federal prison cell for at least several years.

The 66-year-old Yee cut a plea deal with federal prosecutors, avoiding a looming August trial date but forcing him to admit he took payments in return for promises to use his political clout for a host of powerful interests, from NFL owners to medical marijuana businesses. Dressed in a dark suit and calm enough to chat casually with reporters before entering his guilty plea, Yee confessed in his plea agreement that he used his bids for secretary of state and San Francisco mayor as racketeering enterprises to extort bribes for his cash-starved campaigns.

The plea deal was presented in court here to U.S. District Judge Charles Breyer, who will sentence the former Democratic state senator from San Francisco on Oct. 21.

Yee was set to go on trial on political corruption, money laundering and gun trafficking charges in August along with three other defendants: political consultant Keith Jackson, his son, Brandon Jackson, and former sports agent Marlon Sullivan.

Those defendants also pleaded guilty Wednesday under separate plea deals with the U.S. attorney’s office. Keith Jackson, a well-connected San Francisco political consultant accused of being at the center of Yee’s dealings, pleaded guilty to the same racketeering charge as the defrocked state legislator.

Yee’s plea deal avoids a detailed exploration at trial of his political dealings, and could be used to coax some leniency from the judge. But it also spares the government an attack on its sprawling four-year covert investigation, which included FBI undercover agents doling out bags of cash and countless hours of audio and video recordings, including some that crossed paths with numerous high-profile figures who were not implicated in any wrongdoing, including former San Francisco 49ers quarterback Joe Montana and San Francisco Mayor Ed Lee.

Court documents show that Yee did not agree to a particular sentencing range in his plea deal, meaning his lawyers and prosecutors can wrangle over a recommendation to the judge. However, Keith Jackson agreed to a sentencing range of 6 to 10 years, which lawyers familiar with the case say is a likely guidepost for Yee. Yee also agreed to forfeit about $33,000 seized from his campaign accounts to the government.

Yee and his lawyer left court without commenting. Yee’s March 2014 arrest on corruption charges shook Sacramento, coming on the heels of a federal indictment of fellow state Sen. Ronald Calderon for accepting bribes. Yee, who was first elected to the Senate in 2006, had to cut short his quest for statewide office, and the Senate suspended him while his case unfolded.

An FBI probe into Asian organized crime in San Francisco led authorities to Yee’s dealings with Keith Jackson, whose legal team issued a statement saying his role in the case started with the FBI luring him with promises of “great wealth.”

“Keith Jackson has entered an honest plea to what he actually did when the FBI embroiled him in their activities,” James Brosnahan, his lawyer, said.

Brandon Jackson pleaded guilty to a separate racketeering charge that included an allegation he offered to arrange a murder-for-hire. His potential prison sentence is expected to range between four and eight years. Sullivan pleaded to a racketeering charge that carries up to an eight-year sentence.

In the plea agreement, Yee admitted that he traded his political influence for bribes, typically offered by undercover FBI agents. Yee, among other things, admitted he agreed to influence legislation for would-be medical marijuana businesses in California, an NFL team owner trying to exempt pro athletes from the state’s workers’ compensation laws and a fictitious FBI concocted software firm seeking government technology contracts.

The racketeering charge also contained allegations Yee tried to arrange an illegal international arms deal through the Philippines in exchange for money. Yee confirmed his role in that bizarre crime as well.

Yee admitted, for example, accepting an $11,000 cash bribe in June 2013 from an undercover FBI agent to help sponsor statewide marijuana legislation, according to his plea agreement. In addition, he admitted he laundered a $6,800 contribution to his secretary of state campaign in 2014, court records show.

The overall case is not over, and the role of co-defendant and reputed gang leader Raymond “Shrimp Boy” Chow will become central as it goes forward. Most of the racketeering and other charges in the indictment are connected to Chow and his Chee Kung Ton organization. Barring further plea deals, that trial involving dozens of defendants will take place later.

Contact Howard Mintz at 408-286-0236. Follow him at Twitter.com/hmintz.