"Close but no cigar" is one of many English sayings characterized as an idiomatic expression. In general terms, the saying means close to success or nearly correct. It likely derives from a comparison to games played at American fairs in the mid-20th century.
Like many similar expressions, the words in the phrase do not describe an actual physical action or object. Rather, the expression is used in a symbolic sense, representing an idea or thought. Such literary techniques are known as idioms, and they typically consist of a comparison between the literal expression and the idea or thought presented.
The actual terms in "close but no cigar" likely refer to the American fairgrounds of the mid-20th century. Many booths were set up at these grounds where individuals played a game in order to win a prize. During this era, cigars were a common prize given by fair vendors. If an individual did not beat the game, then the vendor might say "close" or "nice try, but no cigar."
In these cases — just as with the modern expression — the words were meant to indicate an endeavor that was almost completed, but ultimately was not completely successfully. One contemporary example might occur when an individual goes for a job interview. If the applicant makes it to final rounds of interviews, but the position is ultimately given to another applicant, then someone might say that the unsuccessful individual's attempt was "close but no cigar." In this case, the "cigar," or prize, would have been the job. Usually, the negative outcome is compounded by the fact that no reward or compensation is given for the effort.
A slightly different interpretation of the phrase might happen if one is seeking an answer to some question or problem. In seeking the correct idea, an individual might put forth a proposed answer or solution. If this hypothesis proves almost correct but still not quite right, then it might be said that the proposal was "close but no cigar."
This saying is believed to have originated in the United States because it first appears in American popular culture. A 1930s cinema version of Annie Oakley’s life contains the phrase “Close, Colonel, but no cigar.” American newspaper reporters also frequently used the phrase in following decades.