A congressional staffer carrying a gun was allowed to move freely inside the US Capitol complex for several minutes on Thursday, even though an X-ray machine at a security checkpoint had picked up the weapon in his bag.

The 57-year-old man told police he had left the pistol in his bag by accident but the incident nevertheless raised serious questions over security at the seat of US democracy, almost a year after the deadly January 6 insurrection.

With numerous dignitaries including President Joe Biden due in the Capitol Rotunda for Republican statesman Bob Dole's memorial, the House of Representatives worker was waved through security at the Longworth office block across the road.

The man, identified as Jeffrey Allsbrooks, was tracked down and detained four minutes after officers noticed the gun -- a delay roughly equivalent to the typical duration of mass shootings in the United States.

The security breach occured in an office block opposite the main Capitol building
The security breach occured in an office block opposite the main Capitol building GETTY IMAGES NORTH AMERICA via AFP / Anna Moneymaker

The US Capitol Police issued a statement confirming that officers "spotted the image of a handgun in a bag on the X-ray screen" after the staffer had passed though security.

But the force did not reveal exactly how long he had been in the building before the breach was spotted, and did not respond to a request for confirmation of media reports that the gun was loaded.

"Allsbrooks told our officers he forgot the gun was in the bag. We are charging him with carrying a pistol without a license," the statement said.

"This case remains under investigation and the department is looking into what happened before, during and after those four minutes."

The casket of former US senator Bob Dole arrives at the US Capitol in Washington, DC where it will lie in state on December 9, 2021
The casket of former US senator Bob Dole arrives at the US Capitol in Washington, DC where it will lie in state on December 9, 2021 POOL via AFP / MANDEL NGAN

The agency sent out an alert just before 8:00 am notifying Longworth staff of a security threat and telling them to lock themselves in the nearest office and stay away from all doors and windows, or "seek cover if in a public space."

Staff were prevented from entering or leaving the building during the lockdown, which was lifted after a few minutes.

The arrest came with Biden preparing to pay tribute to former Republican senator and presidential candidate Dole, who is lying in state in the Capitol.

The police have been on high alert since one of their officers died and numerous others were wounded after thousands of supporters of defeated president Donald Trump stormed the Capitol on January 6 in a bid to overturn Biden's election victory.

Security was tested again on April 2 when a man rammed a car into police at a barricade outside the complex, wounding one officer.

And government offices were evacuated when a motorist stopped his pickup truck outside the Library of Congress, across the road from Congress, in August and said he had explosives.

A month later Capitol police arrested a man who had multiple knives, including a machete, in his truck near the Democratic National Committee headquarters in the same area.

Allsbrooks didn't respond to a request for comment.