knowyourphrase.com - The Origins of Phrases and the Meanings of Sayings
Note: The origins for a phrase are very unclear, much of the time. The origins you see listed here are the plausible theories floating around for how or where an idiom came from, but may not necessarily be accurate. The quotes which have the phrase in them are pretty much the oldest written forms of the phrase I could find, but keep in mind that older recordings could exist and I am simply unaware. If you find an earlier citation than what I have, feel free to let me know!
Also, remember that just because you see a saying in an old book or newspaper, let's say from the year 1893, it does not mean the saying originates from that source or from that year. In all likelihood, if an expression is already being used in a book or newspaper, then it's probably already well established at that time and dates back even further. Nevertheless, these old quotes serve as a way to show readers how far back in history some of these popular sayings go, which is quite interesting!
The origin of this phrase is believed to be rooted in carnivals. Carnivals have many different types of games that can be played, some are based around accurary, others on strength. Prizes are usually awarded to the winners, while the losers are left with nothing at all. The prizes typically consist of big stuffed animals and other types of toys.
Well, apparently there was a time in the 20th century where cigars could also be won as prizes. If this is true, then I could certainly picture the owner in charge of a game shouting this phrase to someone who was close to winning a prize. For example, there's a certain strength based carnival game known as high striker. In this game, the player takes a mallet and swings it as hard as they can at a target. When the target is struck, a metallic object rises up a set distance depending on the severity of the swing; if the target is hit hard enough, a bell rings, indicating that the player has won. It is common, however, for players to fall just shy of ringing the bell, so the owner in charge of the game might tell the player: "Close, but no cigar," meaning that the player had nearly won the prize, but didn't quite make it. Thus, perhaps this expression originates from something along these lines.
This idiom looks to go back to at least 1934, where it appears in writing in a Pennsylvania newspaper called the Chester Times:
"An unseen pedestrian loomed before their headlights, narrowly dodged the sliding wheels.
'Close, but no cigar,' the lieutenant shouted."
Reference: newspaperarchive contained a digital copy of the newspaper with the saying in the quote above.
* Having not fired a crossbow in years, I took my first shot with it this morning at a nearby tree and missed! I was close, but I get no cigar for that attempt.
* My coach yelled 'close, Mike, but no cigar,' when I was unable to break my previous record on the 100 yard dash.