It was literally a riot — students crowded the hallways, screaming at the top of their lungs and protesting what they said was the principal’s decision to close all the bathrooms to students.

“What happened was two students started fighting, and the principal got mad, and closed all the bathrooms, and then all the kids went crazy and just started a riot,” one student said.

The unrest happened Thursday in the middle of the school day.

Students said Principal Andrea Lewis, who started at the school just this fall, got on the loudspeaker and announced bathroom access would be restricted, after what students said were two fights that broke out during class.

The principal is also accused of threatening that anyone caught fighting again would be arrested.

When asked if Lewis did indeed close all the bathrooms, one student said, “You can say that, but she did say if it’s an emergency you can use the bathroom at the nurse’s office. Everybody got mad and it started a riot.”

The bathroom ban was apparently the last straw at the 2,400-student school next to the Brooklyn Bridge. The building is equipped with its own surveillance video, which school officials said was used to identify those involved in the riot, leading to some being disciplined.

But students said it’s the principal who needs discipline over her strict no-bathroom policy.

One student said the principal’s actions were unprecedented.

“No, this was the first time, because she’s really upset,” the student said.