A Manhattan student was slashed with a box cutter Monday when he rushed to the aid of a friend who was being robbed outside their Harlem school, cops said.

Alexis Perez, 15, was in a gym class that is part of a summer program at the Manhattan Center for Science and Mathematics when his pal sent him a frantic text shortly before begging him to open the school’s back door.

“Where you at?’ the message said.

The friend went on to explain that two goons were trying to rob him.

Perez ran out of class, but when he got to the back door, he was approached by the two thugs, one of whom was armed with a box cutter.

Perez got into a scuffle with the armed thief, a tussle that ended with Perez suffering lacerations to his back, head and arms, authorities said.

The suspected thieves fled. There have been no arrests, Perez was rushed to St. Luke’s Hospital, where he received 20 stitches, and was released.

“I was defending my friend,” Perez told the Post. “They cut me with a box cutter. I’m not scared but my mom doesn’t want me to go back to school.”

The high school sophomore was making up three classes that he failed during the year.

Perez said one of the suspects was wearing orange and white and the other was dressed in black.