Play video content EXCLUSIVE TMZSports.com

NBA player Tyler Ulis was attacked and beat up by 2 guys in an apartment elevator fight in 2017 ... until his friend, Devin Booker, came to the rescue ... and TMZ Sports has the footage.

It all went down in Tempe, AZ on May 26 while Ulis was still playing for the Phoenix Suns. We're told Tyler was trying to hold the elevator for his friends when another group of guys tried to get on.

When Tyler continued to hold it ... they took offense and a scuffle broke out. One guy grabbed Tyler while another man put him in a headlock. The fight spilled out of the elevator and into the hallway.

A short time later, Ulis' friends -- including Suns superstar Booker -- took the elevator to the scene of the fight and found the men who attacked Ulis. Another fight broke out, Ulis threw punches.

Booker -- who covered his face with a bandana -- does not appear to hit anyone.

Eventually, the 2 groups get down to the lobby ... where another man from Ulis' crew (wearing a black shirt) chases their adversaries out of the building and punches one of the guys in the face.

You can see Booker chasing after the other men into the street.

We're told police were called to the scene, but ultimately no arrests were made.