Chief Keef got shot at early Saturday morning in NYC, but fortunately the shooter -- or shooters -- missed ... TMZ has learned.

Law enforcement sources tell us ... Keef was shot at around 6 AM outside the W Hotel in Times Square. We're told a shell casing was discovered and police are looking for 2 black males wearing black hoodies who fled the scene.

Our sources say the bullet missed the rapper and struck hotel signage. It's unclear how many shots were fired at this time. Chief's staying at the hotel and was returning after a night out when he was shot at.

What's interesting -- Chief Keef's been in an apparent heated beef on social media with Tekashi69, but we're told at this point there's no connection between that and the shooting. Our sources say 6ix9ine is currently in L.A.