The story opens on a winter night in Moscow, Russia. A card game is being played until four in the morning at the house of Narumov, a Horse Guard. The protagonist Hermann, an officer in the Army Engineers and the son of a German, feverishly watches people gamble, though he has never played, calculating that the risks are too great.
Tomsky tells the story of how his grandmother, Countess Anna Fedotovna, incurred a debt while playing the card game faro in Paris fifty years earlier. When her husband refused to pay, she learned a secret to winning at faro from the mysterious and notorious Count of St. Germain. Tomsky says she only ever told one man about it, Chaplitsky, but ends his story without saying how things turned out for the man.
The point of view switches to Liza, a young ward of the 87-year-old Countess. As the subject of the Countess's abuse, Liza lives a miserable life and longs for a man to rescue her. She begins a flirtation with an Engineers officer who stands outside her window and looks up while she embroiders. It is revealed that the man is Hermann, who has grown obsessed with learning the Countess's secret.
Over three weeks, Hermann writes love letters to Liza until she gives him instructions on how to get to her bedroom by entering the house while she and the Countess are at an embassy ball. Once in the house, Hermann, instead of ascending the spiral staircase to Liza's room, hides in the study next to the Countess's bedroom. Once they return and the Countess sends her servants away, Hermann pleads with her to tell him the secret. She is silent, so he threatens her with a pistol, at which point she dies from fright.
Hermann goes to Liza's room and admits to his calculated plot, though he says he hadn't meant to kill her. Liza is upset to learn his love was in fact greed, but she gives him a key and instructions that let him access a passage out to the street.
At the Countess's funeral three days later, Hermann is horrified when the dead Countess appears to wink mockingly at him. That night her ghost visits his room and tells him she has been ordered to divulge the secret sequence of cards, which are three, seven, and ace.
Hermann goes to the gambler Chekalinsky's house and bets all the money his father had left him on three. He wins, and comes back the next night to double his winnings on seven. The third night, however, Hermann is shattered to discover that he mistakenly bet on his queen of spades rather than his ace. The queen appears to wink at him, just as the Countess's did.
Having lost his money and his mind, Hermann lives in a mental hospital at the end of the story. He answers no questions, merely repeating "Three, seven, ace! Three, seven, queen!"