The mayor of Charlotte, N.C., resigned on Wednesday after he was arrested on public corruption charges, as federal law enforcement officials alleged that he accepted a trip to Las Vegas, use of a luxury apartment and more than $48,000 in cash in exchange for helping smooth out municipal obstacles for undercover agents posing as investors.

Patrick D. Cannon, a Democrat, had been in the mayor’s office only since early December, but he has been involved in city politics since he was elected to the City Council in 1993 at the age of 26.

The undercover operation that led to Wednesday’s arrest began in August 2010, when Mr. Cannon held an at-large City Council seat. Undercover officers claim that they made four payments of thousands of dollars in cash to Mr. Cannon between January 2013 and February of this year.

Mr. Cannon, 47, appeared in federal court briefly on Wednesday and was released on bond pending indictment. He submitted his resignation letter hours later.