A message posted online threatening violence against white students and staff at the University of Chicago was made in retaliation for the fatal shooting of a black teenager by a white police officer, according to federal law enforcement officials.

Jabari R. Dean, 21, was arrested Monday morning after, prosecutors said, he posted a message online over the Thanksgiving weekend threatening to execute 16 students and staff members on the quad of the campus. The threat led the university to cancel classes Monday.

According to a criminal complaint filed in federal court, Mr. Dean wrote he would kill 16 people, a number chosen to represent the same number of times 17-year-old Laquan McDonald was shot by Chicago Police Officer Jason Van Dyke.

Video showing McDonald’s fatal shooting in October 2014 was publicly released Tuesday, the same day Officer Van Dyke was charged with first-degree murder in his death. Officials had worried that the video’s release could ignite violent protests across the city.

Instead, demonstrators gathered in Chicago’s bustling Magnificent Mile, home to many high-end shops, to protest the shooting on Black Friday as a way to harbor retail sales.

In a separate hearing Monday, Officer Van Dyke had his bond set at $1.5 million, which he posted. He was seen by Chicago media leaving jail early Monday evening.

The threat made against the university campus was reported to the FBI on Sunday by a person who saw the threat on a social media website, according to court documents. The person took a screenshot of the threat and sent it to an FBI investigator, who had been unable to locate the message after it had apparently been removed.

“This is my only warning. At 10AM Monday morning, I’m going to the campus quad of the University of Chicago. I will be armed with an M-4 carbine and two desert eagles, all fully loaded. I will execute approximately 16 white male students and or staff, which is the same number of time McDonald was killed,” wrote the commenter, according to the complaint filed in U.S. District Court for the Northern District of Illinois.

“I will then die killing any number of white policeman in the process. This is not a joke. I am to do my part and rid the world of white devils. I expect you do the same,” the writer concluded.

Prosecutors said Mr. Dean, a freshman electrical engineering student at the University of Illinois at Chicago, was arrested sometime before the 10 a.m. deadline for the attack.

A visibly ill-at-ease Mr. Dean appeared in court Monday afternoon, where prosecutors indicated that they’ll agree to his release before trial. The judge ordered Mr. Dean, who is black, be held at least until a Tuesday bond hearing. Mr. Dean didn’t enter a plea and his lawyer declined comment afterward.

According to the criminal complaint, when law enforcement officials went to speak with Mr. Dean, he admitted to making the threat but said he deleted the comment shortly afterward.

Mr. Dean was charged with transmitting a threat to interstate commerce. The charge is punishable by up to five years in prison.

The University of Chicago, where President Obama taught law, first alerted students and staff Sunday night about a threat that mentioned the quad, a popular gathering place, and 10 a.m. Monday.

The statement urged faculty, students and nonessential staff to stay away from the Hyde Park campus through midnight Monday, and told students in college housing to stay indoors. The cancellations of classes and activities affected more than 30,000 people, though the University of Chicago Medical Center was open to patients.

⦁ This article is based in part on wire service reports.