The story
The phrase was commonly used in New York in the 1930s, by both criminals and law enforcement, often with regard to baseless arrests. The phrase was popularized more broadly by its appearance in the film Casablanca (1942), especially since the 1990s.
Etymology from Wiktionary, CC BY-SA 4.0.