JUSTIN BIEBER scolded a fan in front of thousands of people for messing up THE MOMENT.

Bieber was performing in Atlantic City, when some fan tossed a hat onstage while he was talking in-between songs.

It apparently threw Biber off his game so he embarrassed the poor fan.

(WARNING!!!! UNCENSORED VIDEO)

Bieber said, quote, “Take this moment to listen…and try not to give me a hat or whatever you’re trying to throw onto the stage right now, because I probably don’t want that [crap].”

The crowd cheered, and Justin said, quote, “Sorry that was mean. But…I lost what I was going to say.  I was deep into, like, a mode and a zone. I was…I was in it. Now I’m out of it. I’ll get it back. Just give me a second.”

A little while later, he apologized again, and got the show back on track.

Quote, “Sorry for throwing your hat, but you ruined the moment.  Whatever, let’s do it.”