Justin Bieber narrowly dodged the cold hammer of justice this week ... TMZ has learned -- getting off with just a warning after cops pulled the 17-year-old over in his Batman-themed Cadillac.

Law enforcement sources tell us, Bieber was cruising around L.A. in a ridiculous 3-car motorcade -- with Biebs up front in a murdered out Bat-illac CTS-V ... flanked by his friends in a Range Rover and a black Rolls Royce (Sean Kingston).

According to law enforcement sources, JB cut off a CHP officer and was pulled over -- along with the other two cars -- but fortunately for the Biebs and his perfect life, the entire gang was sent on their way with just a warning.

To add insult to injury -- JB's car is maddeningly awesome ... with a custom "JB" logo on the side panel ... and twin Batman symbols on the front and back of the car. Oh yeah, and the word "Batmobile" is emblazoned on the trunk.