The Baltimore police department has used secretive cellphone tracking technology thousands of times in recent years while following orders from the FBI to withhold information about the practice from prosecutors and judges, a detective testified in court on Wednesday.

The testimony of the detective revealed the widespread use of cell site simulators, known as Stingrays, which mimic the signal of cellphone towers to force phones to transmit their data to them. Police can then analyze the data to track the location of the phones.

Detective Emmanuel Cabreja said in his testimony that the Baltimore police department had used the device, called the Hailstorm -- an upgraded version of Stingrays -- and other similar technology about 4,300 times since 2007, the Baltimore Sun reported. This is believed to be much higher than other known cases where similar equipment has been used by state and local police.

The testimony marks one of the rare instances where details about the device have been divulged, as federal officials have tried to downplay its use. The government has intervened in relatively minor public records cases and criminal trials to advise local police forces to withhold details about the technology, according to documents obtained by the Associated Press (AP). The documents require the police department to obtain FBI authorization before sharing information about the Stingray technology with other law enforcement authorities.

Cabreja said he did not comply with a subpoena to bring one of the devices to court because of a nondisclosure agreement the Baltimore police signed with the FBI. The agreement, which was presented in court on Wednesday, instructs prosecutors to drop cases if they find themselves pressed on the technology, and tells them to contact FBI agents if they are questioned by lawmakers or judges.

"Does it instruct you to withhold evidence from the state's attorney and the circuit court of Baltimore city, even if upon order to produce?" Defense Attorney Joshua Insley asked him during questioning. “Yes,” Cabreja replied, and added that he had spoken to the FBI last week regarding the case.

The case in which the technology came under scrutiny involves a carjacking and robbery, to which 21-year-old Nicholas West and his juvenile co-defendant Myquan Anderson pleaded guilty on Wednesday.

The use of the Hailstorm and other Stingray devices as well as the secrecy surrounding the operation has been criticized by civil liberties groups.

"This is a very expensive and very invasive technology developed for military use, now used on the streets of America," Nathan Freed Wessler, a staff attorney with the American Civil Liberties Union, told the AP.

"The public has a right to know how taxpayer dollars are being spent, and if our constitutional rights are being respected," he said. Their use has been controversial elsewhere in the United States as well. On Tuesday, it was revealed that the police department of Erie County in New York has used the device 47 times since 2010, with only one of those instances being authorized by a court despite a previous assertion that the use of Stingrays is subject to “judicial review.”

In March, a federal official admitted that the Stingray could possibly be used for mass disruption of cellphone service in an area, in addition to specifically targeted phones. Authorities have insisted that officials limit the use of the device to surveil and disrupt targeted phones only.