12:02 PM PT -- According to legal docs -- obtained by TMZ -- cops discovered a lunch box in the vehicle that contained weed. The docs say Davidson's friend also had a "white/yellow substance in a clear plastic bag" that tested positive for marijuana.
Pete Davidson was pulled over by cops in Upstate New York ... but even though he was behind the wheel it was his boy who ended up going to jail.
Sources with direct knowledge tell TMZ ... Pete and his friend were driving in Syracuse around 4 AM last weekend where Pete was filming "Big Time Adolescence" with Machine Gun Kelly. It's unclear why, but cops ordered him on the side of the road. We're told officers smelled weed ... triggering a search.
Sources say Pete passed a field sobriety test, so he was in the clear. His friend, however, wasn't so lucky.
According to an arrest report -- obtained by TMZ -- the friend was booked for felony possession of a controlled substance and cited for unlawful possession of weed. As for the controlled substance ... cops aren't saying what they found.
Here's what we don't know ... there were drugs in the car, but we don't know why cops fingered the passenger.
We've reached out to Pete's rep, so far no word back.