SAN FRANCISCO — Known for navigating the state Capitol’s backrooms and this city’s complicated political landscape, state Sen. Leland Yee now is accused of consorting with notorious felons, accepting money for his cash-strapped political campaigns in exchange for favors and promising undercover FBI agents he could deliver connections to international gun runners.

In a stunning development that almost certainly torpedoes Yee’s quest for statewide office, the San Francisco Democrat wound up glum and disoriented in a federal courtroom Wednesday. The politician who introduced anti-gun-violence legislation is now charged with trafficking in firearms and public corruption in an FBI undercover operation that could land him in prison for years.

Democratic leaders in Sacramento, already stung by another recent federal corruption case, exhorted Yee to immediately step down. Senate President Pro Tem Darrell Steinberg, D-Sacramento, called the allegations against Yee “shocking” and “surreal.”

“Senator Yee should leave the Senate and leave it now,” he said.

With scenes resembling the recent movie blockbuster “American Hustle,” Yee is depicted in a startling, 137-page FBI affidavit of repeatedly offering to broker illegal firearms sales in exchange for campaign contributions. He allegedly took part in dealmaking meetings with undercover agents, often arranged by San Francisco political consultant Keith Jackson, a close associate among two dozen figures charged in the case.

Yee is linked to a host of wrongdoing to pad his political warchest, charged with seven felonies in a case with two dozen defendants accused of everything from money laundering to murder-for-hire. The defendants include Raymond “Shrimp Boy” Chow, a reputed ringleader of a Chinese syndicate federal investigators have been trying to crack since the late 1980s.

A federal magistrate judge released Yee on $500,000 bond, and he brushed past a swarm of reporters and left the courthouse in a dark blue BMW. Paul DeMeester, Yee’s lawyer, said he was encouraged the senator was released and added: “The future will hold a lot of work.”

The government’s case will no doubt be challenged as the case unfolds. It rests largely on the FBI’s accounts of Yee’s meetings with undercover agents, which include alleged attempts to improperly land cash for his current secretary of state campaign.

But as recently as last month, Yee was engaged in the secretive meetings, at one point telling an undercover operative with whom he was trying to cut an arms deal that he was ready to cash in on his connections in Asia if he lost his current bid to become secretary of state, according to court papers.

Yee, who once championed a California law that would have outlawed violent video games, told undercover operatives that he had ties to an international arms dealer with connections as far-flung as Russia, during one meeting saying: “Do I think we can make some money? I think we can make some money,” according to the FBI affidavit.

The charges surfaced during a whirlwind day of law enforcement raids around the Bay Area, where Yee was arrested early in the morning at home and Chow was hauled from bed by federal agents. In all, the criminal complaint unsealed Wednesday charges 26 people — including Yee and Chow — with crimes including firearms trafficking, money laundering, murder-for-hire, drug distribution, trafficking in contraband cigarettes and “honest services” fraud. That last charge is the centerpiece of the case against Yee and Jackson and effectively alleges they attempted to secure political donations in exchange for their help, including arranging the firearms deals. But federal agents never culminated the arms deals through Yee, though they did give him cash, the affidavit says.

Yee is charged with conspiracy to traffic in firearms without a license and to illegally import firearms, and six counts of scheming to defraud citizens of honest services. Each corruption count is punishable by up to 20 years in federal prison and a fine of up to $250,000, while the gun-trafficking count is punishable by up to five years and $250,000.

The charges are particularly shocking given that Yee has been among the state Senate’s most outspoken advocates both of gun control and of good-government initiatives.

“I’m just astonished,” said Corey Cook, director of the University of San Francisco’s Leo T. McCarthy Center for Public Service and the Common Good. “Political corruption is one thing, but this is a whole other level.”

Jackson, a former school-board president, allegedly was the link between Yee and undercover agents, as well as Chow, who federal prosecutors say is the current “Dragonhead,” or leader, of the San Francisco-based Ghee Kung Tong organization, spelled in court documents as Chee Kung Tong.

Chow introduced an undercover agent who had infiltrated his organization to Jackson. With his son, Brandon Jackson, and another man, Marlon Sullivan, Keith Jackson allegedly sold the agent guns and bulletproof vests. The Jacksons and Sullivan also allegedly conspired in a murder-for-hire scheme requested by the undercover agent, as well as other crimes, including sale of stolen credit cards and purchase of cocaine. There is no link in the FBI document between Yee and the murder-for-hire scheme.

An FBI affidavit says Keith Jackson last August told one of the undercover agents that Yee was “associated with a person who was an international arms dealer who was shipping large stockpiles of weapons into a foreign country.” At later meetings in August and December, Jackson said Yee had agreed to help set up an arms deal; the agent first gave Jackson $1,000 cash for his help and later cut a $5,000 check from a bogus company to Yee’s campaign.

At one meeting, agents pressed Yee and Jackson for shoulder-fired weapons or missiles, the affidavit says; Yee asked whether he wanted automatic weapons, and the agent confirmed he did — about $500,000 to $2.5 million worth. Yee told the agent “he saw their relationship as tremendously beneficial,” the affidavit says, adding he wanted the agent and Jackson to make all the money because he didn’t want to go to jail. The agent replied he would pay Yee and Jackson hundreds of thousands of dollars over time and more immediately would pay $100,000 for the first arms deal. “Senator Yee said ‘All right, take care.’ The meeting ended.”

But during one meeting, Yee appeared spooked by the federal indictment of state Sen. Ronald Calderon; the two shared a desk on the Senate floor. Yee, the affidavit alleges, discussed specific locations in the Philippines and Florida that might be ideal for moving the guns, which he said would include M-16-type automatic rifles.

Yee, Jackson and Wilson Lim and the agent met again later; Yee said the arms deal wouldn’t be done until after this year’s elections. “Senator Yee explained, ‘Once things start to move, it’s going to attract attention. We just got to be extra-extra careful,'” the affidavit says.

Finally, they all met March 14, where they discussed how they would break up the undercover agent’s money into legitimate campaign donations. The agent told Yee he was prepared to give Yee $6,800 cash and a list of weapons he wanted; Yee replied “he would take the cash and have one of his children write out a check.”

Yee is the state’s third Democratic legislator recently targeted in corruption allegations. In February, state Sen. Ron Calderon, D-Montebello, surrendered to authorities after being indicted on bribery charges. In January, state Sen. Roderick Wright, D-Inglewood, was convicted of voter fraud and perjury stemming from a 2010 indictment.

Staff writers Thomas Peele, Robert Salonga, Mark Gomez and Erin Ivie contributed to this report.