His mother, Darcelle Jenkins, a former case specialist in the Worcester Juvenile Court, is also facing drug charges after police investigating the witness intimidation case raided her home.

Mr. Perez is one of eight people charged with posting grand jury documents online using social media in an attempt to keep the alleged victim of a 2010 shooting from testifying.

In Hampden County Juvenile Court on Friday, under heavy security, Mr. Perez was upset when he learned the judge would not decide his case until next week.

"I have to go back to the program?" he asked his lawyer, Leonardo A. Angiulo.

He told his lawyer he has trouble sleeping as he was being led from the courtroom wearing a black Worcester Vikings T-shirt, gray sweatpants, and silver and blue sneakers.

During the case before Judge Daniel J. Swords, Worcester Police Detective Michael Tarckini testified that police began investigating the witness intimidation after the alleged victim, Luis Rosario, became fearful of testifying.

On social media, he said, police found Twitter postings known as "tweets" with the hashtag "#Luisrosariotherat" and pictures of sealed grand jury testimony that was only available to a few people.

Detective Tarckini also said there were emoticons — cartoon-like symbols — depicting a rat, a gunshot and a gun, "indicating the gun shoots the rat," posted online.

The online messages were tracked to a Playstation that Detective Tarckini said was seized, along with a cellphone, when police raided the home in Holden in which Mr. Perez lived with his mother.

The detective said Mr. Perez had the cellphone in his hand and was in a back bedroom with Leroy Edmonds, who has also been charged in the case, when they arrived.

During the hearing, Assistant District Attorney Terrance M. Reidy said there have been escalating problems between rival gangs in Worcester. He said gangs affiliated with Kilby Street and their rivals, Plumley Village East, are "highly volatile."

Releasing Mr. Perez would not insure the safety of citizens, he said during closing arguments.

But Mr. Angiulo said Mr. Perez was never charged in many of the incidents Mr. Reidy raised to prove he is a danger.

He said Mr. Perez "cannot help who his family members are," after hearing that he has uncles who are members of the Kilby gangs.

And Mr. Angiulo argued that when Mr. Perez talked in the school principal's office about shooting his girlfriend who he'd recently learned was pregnant, he was "letting loose" and "might not know any other way of expressing himself."

Judge Swords said he would review the 25 exhibits Mr. Reidy presented, many of which were objected to by Mr. Angiulo. Some are YouTube videos, and one contains a jailhouse call placed to Ms. Jenkins in which she told an inmate that Mr. Rosario was going to be coming to the Worcester County Jail and House of Correction in West Boylston after a shooting.

During the conversation, Detective Tarckini said, Ms. Jenkins "excitedly supported" the inmate's threat to "wipe him (Mr. Rosario) down." The detective said that phrase refers to a beating.

While Mr. Perez's voice is heard on the tape, he did not promote the beating, Detective Tarckini said.

Judge Swords said he expects to rule at 2 p.m. Wednesday on whether Mr. Perez can be released and if any conditions will be set.

He is being tried as a youthful offender, which means the juvenile proceedings, typically held in private, are open.

Ms. Jenkins wept as her son was led from the courtroom while telling her he loved her.