CHICAGO (AP) — A veteran Illinois state senator charged with trying to board a flight with a gun and ammunition in a carry-on bag was released on bail Thursday.

A Cook County judge set bond at $25,000 for state Sen. Donne Trotter, who recently announced he was running for Jesse Jackson's old seat in Congress. Trotter's defense attorney argued for reasonable bail citing Trotter's decades of public service and 26-year marriage.

"He's lived a life dedicated to serving the people of Illinois," defense attorney Joshua Herman said.

Trotter was released from custody a short time later. The Chicago Democrat refused to answer reporters' questions before walking away from the courthouse.

Trotter was going through security at Chicago's O'Hare International Airport on Wednesday when Transportation Security Administration officers found during routine X-ray screening an unloaded handgun in an outside zippered pocket of his garment bag. Also found was a magazine clip with six bullets.

The 62-year-old father of four was charged with a Class 4 felony, which carries a sentence of one to three years in prison if he is convicted.

After being stopped at O'Hare, Trotter told officers he uses the .25-caliber Beretta handgun for his job with a security company.

"He did not realize it was still in his bag," assistant state's attorney Lorraine Scaduto said.

Trotter got off work with the security firm at midnight and the weapon was still in his bag when he packed at 4:30 a.m. for the flight to Washington, Scaduto said Trotter told authorities. The weapon is registered, but not in the city of Chicago where Trotter lives, she said.

Trotter is licensed to carry a weapon and has a firearm owner's identification card, according to police. He was also carrying a firearm control card issued by the Illinois Department of Financial and Professional Regulation, which allows him to carry a weapon during work hours and for no more than an hour commuting to or from work.

Trotter is considered a serious contender for Jackson's seat, thanks to his long career in state politics. He was in the Illinois House from 1988 to 1993, and has been in the Illinois Senate ever since, chairing the Democratic majority caucus.

Under former Senate President Emil Jones, he was the Senate Democrats' budget negotiator and known as a cool, calm presence in the often-contentious budget debates during the tenure of ex-Gov. Rod Blagojevich, who is now imprisoned on corruption charges.