DCI officers caused a commotion at the Milimani law court during the arrest of a Cameroonian national who had been freed by a court.
Doccta Longa was rearrested moments after the DPP dropped the charges of being in the country illegally.
The foreigner had been booked for flouting immigration laws by returning to Kenya last month after he was deported on January 6, 2017.
Chief Magistrate Francis Andayi had scheduled the matter for mention on Thursday.
This was after Longa's lawyer Harun Ndubi opposed the withdrawal of the charges.
Ndubi argued that the DPP and police [DCI] are acting with extreme malice and discrimination against Longa.
He further said that the state prosecutions office cannot withdraw the case without the permission of the court, prompting Andayi to schedule the case for a mention.
But minutes after the parties agreed, Parklands DCI officers, led by deputy OIC Inspector Nathan Njoroge attempted to arrest Longa.
They waited for Longa outside the courtroom but he overpowered the offices and ran back to the judge pleading for intervention.
The drama, which lasted several minutes, brought the differences between DPP Noordin Haji and DCI boss George Kinoti to light.
"They have discredited and defiled the court," Ndubi told said after the melee subsided.
"It is now clear that what is happening against the accused [Longa] is blatant prejudice, malice and a show of highest state of impunity."
Inspector Njoroge was summoned by Andayi after the commotion but said he was under instruction by Kinoti to arrest Longa.
"What has happened here is very ugly and I will take it up with other levels," an enraged Andayi said.
The Cameroonian was arrested outside the courts after Andayi ordered he be escorted to the police station by his lawyer. Ndubi did not leave with Longa.
State counsel Kajuju Kirimi had told the court she was under instructions to withdraw charges against the Cameroonian.
She invoked Section 87 of the Criminal Procedure Code and later said she could not understand why the detectives wanted to arrest Longa.
"The conduct of the officers is in question because by withdrawing the case, it was an indication that we are not interested in pursuing any matters against the suspect."
Longa had been arrested by the DCI officers outside the Nairobi Area remand and was released on bond on July 20 before he was arrested again.