CHICAGO (Reuters) - An Illinois state senator running for former Democratic U.S. Representative Jesse Jackson Jr.'s seat in Congress was released on bond on Thursday, following his arrest for trying to bring a gun onto an airplane.

A Cook County judge set bail at $25,000 for Donne Trotter, 62, on the felony charge. Trotter, who has called the incident an honest mistake, posted bond and was released shortly afterward.

If convicted, Trotter could face a sentence ranging from probation to up to four years in prison, according to prosecutors.

Trotter, a Chicago Democrat, is a gun control advocate who once voted "no" on a measure that would have allowed state residents to carry concealed weapons in 1995.

Last week, Trotter joined the crowded field of candidates hoping to succeed Jackson, who resigned from Congress on November 21. Democrats hold a primary on February 26 to select their candidate in the heavily Democratic district, with the election on April 9,

Trotter did not comment after the hearing, but later told reporters outside his home that he planned to stay in the congressional race, according to a broadcast on the local ABC television network.

"I intend on staying in the race at this time and will continue to campaign for the people of the 2nd District," Trotter said.

Prosecutors said Trotter's handgun was not registered with the city of Chicago, as required by municipal ordinance. He had a valid Firearm Owner's Identification Card and a permit allowing him to carry his gun to and from work.

He was arrested on Wednesday at O'Hare International Airport after security officers spotted a .25 caliber Beretta in his garment bag. Trotter has a job as a security guard and said he did not know the gun was in his bag, according to court records.

In the Illinois statehouse since 1988, Trotter is among several Illinois lawmakers who have fallen afoul of authorities this year. Two other state lawmakers have been indicted, and Jackson acknowledged in his resignation letter that he was under investigation by federal authorities.

The charge does not bode well for Trotter's congressional run, said Jeffrey Hill, chair of the political science department at Northeastern Illinois University.

"For someone who was arguably the front-runner in the campaign, this could only increase the probability he'll face good competition," Hill said.

(Editing by Mary Wisniewski and Peter Cooney)