At the Green Manors mental hospital in Vermont the beautiful and brilliant young psychoanalyst Constance Peterson (Ingrid Bergman) is known for being quite aloof from the romantic advances of her fellow doctors. She is only interested in her work. The head of the institution, the elderly Dr. Murchison (Leo G. Carroll) is retiring, involuntarily. He had had an episode of nervous exhaustion from overwork, and the board had decided that this could happen again and he needed to retire. He is to be replaced by the renowned young Dr. Edwardes, who has published an acclaimed book about guilt complexes.
Dr. Edwardes (Gregory Peck) arrives. There is immediate magnetism between him and Dr. Peterson. But some disturbing developments occur. At dinner on the first evening, he has a bizarre and inappropriate outburst upon seeing Dr. Peterson draw the outline of a proposed swimming pool, using the tines of her fork, on a linen napkin.
As the days go by, the friendship between Drs. Edwardes and Peterson grows closer. She goes to his room late one evening, and they declare their love for each other. But while they are embracing, he has another bizarre reaction upon seeing the parallel stripes on her white robe. Then he receives a phone call. One of the patients has become very agitated and tried to cut his throat; he is in surgery. Drs. Edwardes and Peterson go there. Dr. Edwardes has a serious panic attack in the operating room. He is taken to his own room. While Dr. Peterson is watching over him, she notices that his autograph in a copy of his book, which she has borrowed from the library, is very different from the signature on a note that he had written to her. This person is not Dr. Edwardes.
When he wakes up, Dr. Peterson confronts him. He says that he does not know who he is. He killed the real Dr. Edwardes, and is taking his place. He has complete amnesia. His only connection to reality is that he has a cigarette case with the monogram "J.B.". She says that she trusts him completely, and will help him. The police will not come immediately, and she may be able to straighten out the mystery. He should sleep, and she will report in the morning that he is too ill for work. But during the night, he writes her a letter saying that he can't involve her in this, because he loves her. He is going to the Empire State Hotel in New York. He slips the note under her door and disappears.
The next morning, the police have arrived. They were tipped off by the real Dr. Edwardes' secretary, saying that when she had telephoned him at Green Manors, she didn't recognize his voice. They show his photograph to the staff, and they all agree that that isn't the "Dr. Edwardes" that they know. "Dr. Edwardes" is of course missing. They go to see Dr. Peterson in her room. She says that she left Dr. Edwardes in his own room, and that he was too agitated to say anything sensible. She also notices the letter on the floor near her door, but is too frightened to pick it up while the others are present. The police and other staff members leave. Dr. Murchison is the last to leave, and, seeing the letter on the floor, picks it up and politely hands it to Dr. Peterson. She reads it after the others have left.
The next day she goes to the hotel in New York. After managing to find out his room number by recognizing his handwriting on the hotel registration cards (he registered as "John Brown"), she goes to his room and talks to him. She wants to use her psychoanalytic expertise to cure him of his amnesia and guilt complex. He believes that he must have killed Dr. Edwardes, taken his identity, and come to Green Manors. But she is absolutely convinced of his innocence.
She notices that his left hand has been burned. He relives some kind of accident that he must have been in, but can't remember any more details. She asks him an abstruse medical question, and determines from his accurate answer that he must have been some kind of doctor. But when they find out that her name and picture are in the newspaper, they have to make a quick exit from the hotel. They go to Grand Central Station to take a train somewhere.
At the station, Constance tells J.B. to free-associate when he gets to the head of the ticket line, and when the clerk ask for the destination, say the first thing that comes to his mind. He requests two tickets to Rome. Constance explains that he means Rome, Georgia. After they get their tickets, Constance realizes that a policeman saw them, and will recognize them soon, so they can't go to Georgia. They instead take a different train to Rochester, New York, home of Dr. Alex Brulov (Michael Chekhov), who was Dr. Peterson's teacher, analyst, and mentor.
On the train trip, J.B. recalls that he was in the Army Medical Corps, flying over Rome, Italy, and his plane was shot down. He was burned at that time.
When they arrive, Dr. Brulov is not in, but two men are present. It turns out that they are policemen, wanting to know what Dr. Brulov knows about Dr. Edwardes. Dr. Edwardes disappeared on a trip in the Cumberland Mountains with a patient of his. The elderly Dr. Brulov arrives. He is a stereotypical (complete with a beard and a German accent) old-school Freudian. He is not friendly to the policemen, and tells them that he disliked Dr. Edwardes. "What kind of an analyst is it, who wants to cure psychosis by taking people skating? Or to a bowling alley?" After the police leave, Constance announces that she is married, and introduces her husband John Brown. Dr. Brulov is delighted for her, though he says, in his strict old-school way "Women make the best psychoanalysts, until they fall in love. After that, they make the best patients." He offers to put them up in his spare bedroom, and bids them goodnight with "Happy dreams, which we will analyze at breakfast."
In the bedroom, J.B. is concerned that, while they got past the police, Dr. Brulov might suspect something. Constance assures him that Alex is actually not very savvy in social situations. (She is wrong.) J.B. has another anxiety attack while looking at the bedspread, which is white with textured embroidery in parallel lines. Dr. Peterson realizes that parallel lines on a white background seem to be what sets off these attacks.
Medical ethics, not to mention 1945 movie studio sensibilities, require that J.B. sleep on the sofa while Constance takes the bed. During the night, J.B. wakes up, realizes that he is seriously in need of a shave, and goes into the bathroom. While mixing the shaving soap, he has another episode, set off by the white color of the soap, the sink, and the bathtub. He goes downstairs, in a trance-like state, still holding a straight razor. Dr. Brulov is downstairs, having awakened in the night and gone to do some work. He offers J.B. a glass of milk. He has noticed the razor, and he secretly puts a large dose of sedative in J.B.'s milk.
In the morning, Dr. Peterson comes downstairs, wondering whether J.B. has left. Dr. Brulov points to him, sleeping on the sofa. Alex and Constance then exchange sharp words. Dr. Brulov tells Constance that he knows that J.B. is quite possibly a murderer. "The moment I see you with a husband, whose pupils are enlarged, who has a tremor of the left hand, who is on a honeymoon with no baggage, and who's name is John Brown, I know practically what is going on." He is going to call the police. Dr. Peterson tells him that she knows he must be innocent, because "I couldn't feel this way toward a man who is bad." She couldn't love him if he were guilty. Dr. Brulov then mocks her mercilessly. "You are twenty times crazier than him. 'She couldn't love him if he were no good.' This is baby talk." "We both know that the mind of a woman in love is operating on the lowest level of the intellect." She finally persuades him to help her cure him, and hold off for a few days on calling the police.
Dr. Brulov awakens J.B. and begins some rather stern therapy. J.B. has had a dream. Dr. Brulov tells him that dreams contain a window into whatever the person is trying to hide, but they are in terms of puzzle pieces that are all mixed up.
What follows is the famous "dream sequence", designed by the renowned abstract impressionist artist Salvador Dali. The dream is full of fantastical images and psychoanalytic symbolism. J.B. is in a gambling casino, surrounded by drapes with eyes painted on them. The other patrons have blank faces. He deals the seven of clubs to a man with a beard, who says that he has 21 and has won. But the opponent's other cards are blank. Then the proprietor comes over and accuses the bearded man of cheating. He says "This is my place, and if I catch you cheating again, I'll fix you."
In the next scene, the man with the beard is leaning over the sloping edge of a high building. J.B. yells at him to watch out, but he falls over the edge. Then the proprietor appears from behind a chimney, holding a wheel. He drops the wheel. In the next scene, J.B. is running down a slope, with a large winged creature overhead.
After relating the dream, J.B. begins to have another episode. Drs. Brulov and Peterson realize that he saw the view out the window, where children are sledding in the snow, leaving parallel tracks. They realize that the phobia must have arisen from seeing ski tracks, and that he must have been skiing with Dr. Edwardes.
J.B. begins to recall the ski trip. Thanks to the clue of the "angel wings", they piece together that the place was called Gabriel Valley. Constance convinces J.B., against much resistance, that he was traumatized by something from his childhood, and that they must go to Gabriel Valley and unlock that secret and figure out what happened to Dr. Edwardes.
They go skiing, with much apprehension on the part of J.B. There is a dangerous precipice at the bottom of the hill. J.B. recalls it at the last instant, and also recalls a brief incident from his childhood. He was sliding down an outdoor banister, and accidentally knocked his brother off, causing him to be fatally impaled on a fence. He stops himself and Constance just in time. "I didn't kill my brother. It was an accident."
His memory has returned. Back at the ski lodge, he recalls that his name is John Ballantyne. He went to Columbia Medical School, was injured in the war, and was discharged and treated for nervous shock by Dr. Edwardes. They had gone skiing, and Dr. Edwardes, who was ahead of J.B., went over the edge to his death. He also remembered that, prior to the ski trip, he had had lunch with Dr. Edwardes at some club in New York.
But the police have followed them to Gabriel Valley. They found the body of Dr. Edwardes, but there was a bullet in him. J.B. is taken away, convicted of murder, and sent to prison.
Dr. Peterson goes back to Green Manors. Dr. Brulov visits her and offers his heartfelt sympathy for her loss. After he leaves, Dr. Murchison, who is back as head of the institution, also offers his sympathy. During their conversation, Dr. Murchison lets slip that he knew Dr. Edwardes slightly. The words reverberate in Dr. Peterson's mind. If he knew Dr. Edwardes, he would have known instantly that he was an impostor when he arrived at Green Manors. She reaches a devastating conclusion, and confronts Dr. Murchison about it. She discusses John Ballantyne's dream.
The casino symbolized both Green Manors and the restaurant in New York where John had dined with Dr. Edwardes. The eyes on the walls were the staff of Green Manors. The card suit, and the number 21, indicated that the restaurant was the Twenty-One Club. The bearded man playing cards with J.B. was Dr. Edwardes. The man threatening him was Dr. Murchison himself. Then the most devastating symbol: The "wheel" that he was holding was a revolver. Dr. Murchison hid behind a tree, shot Dr. Edwardes, and dropped the gun. The police will be able to trace Dr. Murchison to the Twenty-One Club and Gabriel Valley, and will find the gun, with Dr. Murchison's fingerprints.
Dr. Murchison then reveals that they won't find the gun there, because it is in his desk. He pulls it out and threatens to kill Dr. Peterson. She slowly walks away. He does not kill her, and, after she has left the room, turns the gun around and kills himself. The blast from the gun is in bright red, the only instant in the movie that isn't in black-and-white.
In the final scene, Constance and John are boarding a train for their honeymoon, and Alex Brulov is wishing them well.