Getty Composite

Supreme Court Justice Sotomayor Bodyguard Shoots Alleged Carjacker ... Outside Her D.C. Home!!!

United States Marshals guarding Supreme Court Justice Sonia Sotomayor's Washington D.C. residence shot a suspected carjacker ... and the feds say the suspect was packing heat.

According to legal docs, obtained by TMZ, the feds say the shooting went down early Friday morning around 1:15 AM when the alleged suspect, 18-year-old Kentrell Flowers, approached one of the Marshals parked in an unmarked government vehicle and pointed a handgun at him through the front driver-side window in an attempted carjacking.

The docs say the Marshal drew his gun and fired four shots through the window at the suspect, with bullets hitting Flowers in the mouth. A second Marshal rushed over from another car and fired his gun too and one of the Marshals gave Flowers first aid.

Police say the suspect was arrested and transported to a local hospital for treatment of non-life-threatening injuries.

Flowers is charged with armed carjacking, carrying a pistol without a license and possession of a large capacity ammunition feeding device ... and cops shared an image of a firearm they say was recovered at the scene -- a .40 caliber Smith & Wesson, model 40VE.

The feds say the gun did not have a round in the chamber, but there were 8 rounds of .40 caliber bullets in the 13-round capacity magazine.

The location of the shooting matches the residential block for Sotomayor's condo ... and Daily Mail was first to report the Marshals involved were part of the Justice's security detail.

Our law enforcement sources tell us carjackings in Washington D.C. are very prevalent and this incident appears random and not targeted.

Unclear if Sotomayor, who was appointed to SCOTUS by former president Barack Obama, was home at the time of the shooting.

Click here for info about our online advertising practices.