No one was hurt, officials said. It was not immediately clear who fired the shots or why.
The gunfire erupted as Philippine authorities tried to arrest Senator Ronald dela Rosa, a former national police chief who enforced former President Rodrigo Duterte's anti-drug efforts in which thousands of mostly petty suspects were killed from 2016 to 2018.
Allied senators took Dela Rosa into "protective custody" on Monday, when he reappeared after months of absence.
Several senators were still in the building after holding a session when the gunshots were heard by a throng of journalists, including two from The Associated Press.
Armed security personnel, including military members, ran around with guns ready and later asked employees to leave as tensions started to ease.
Senate President Alan Cayetano briefly appeared before journalists in the Senate shortly after the shots were fired, but could not provide details.
"The emotions are high here," Cayetano said.
"This is the Senate of the Philippines, and we are allegedly under attack."
Interior Secretary Juanito Victor Remulla Jr later arrived with top police officials and said he was deployed by President Ferdinand Marcos Jr to secure the senators.
He said he did not come to arrest dela Rosa, who remained in the building.
An investigation was underway, and security cameras would be reviewed to find out who was behind the gunfire and their intentions, Remulla said.
On Monday, the ICC unsealed an arrest warrant for dela Rosa.
Originally issued in November, the warrant charges dela Rosa with the crime against humanity of murder of "no less than 32 persons" between July 2016 and the end of April 2018, when he led the national police force under Duterte.
Dela Rosa, 64, has vowed to fight the ICC arrest order.
He called on his followers on Wednesday night to gather in the Senate to prevent what he said was his impending arrest.
National Bureau of Investigation agents tried to arrest dela Rosa on Monday, but he managed to dash to the Senate's plenary hall and sought the help of fellow senators.
Cayetano said then that he would cite the government agents involved for contempt.
Duterte was arrested in March last year and flown to the ICC's headquarters in The Hague.
He is still in detention in the Netherlands and faces a trial in the killings from his crackdown, in which dela Rosa has also been accused.
"We should not allow another Filipino to be brought to The Hague, the second one after President Duterte," dela Rosa said, addressing his followers in a Facebook message and blaming politics for his predicament.
Duterte withdrew the Philippines from the ICC in 2019 in a move human rights activists say was aimed at escaping accountability.
The ICC, however, said that it retained jurisdiction over crimes committed when the Philippines was still a member and successfully moved to have him arrested, the first former Asian leader to fall into such disgrace.