While pursuing a criminal across the rooftops of San Francisco, detective Scottie Ferguson slips and finds himself dangling from the gutter of a tall building. A colleague falls to his death in an attempt to rescue Scottie as he looks on in horror. In the apartment of his ex-fiancée, Scottie and Midge discuss his career plans in light of his newly discovered acrophobia, which has prompted him to quit the police force. Scottie is contacted by college acquaintance Gavin Elster, who has heard of Scottie’s accident and wishes to hire him to trail his wife Madeleine, who Elster believes is possessed by the spirit of her great-grandmother Carlotta Valdes. Scottie later learns from Elster that Carlotta committed suicide at age twenty-six—Madeleine’s current age—and he fears that Madeleine, too, has suicidal tendencies. Scottie is initially skeptical but begins to follow the beautiful and mysterious Madeleine in her wanderings around San Francisco, eventually tracking her to the McKittrick Hotel, where he learns Madeleine spends time under the name Carlotta Valdes. Scottie and Midge learn the story of Carlotta Valdes and her San Francisco manor from bookstore owner and local historian Pop Leibel, and they later discover that the McKittrick hotel is in fact Carlotta’s former home.

The next day, Scottie continues to trail Madeleine, this time to a spot under the Golden Gate Bridge, where he watches her throw herself into the San Francisco Bay. Scottie dives in and rescues the unconscious Madeleine and drives her to his apartment, where he undresses her and puts her to bed. When Madeleine awakens, she claims not to remember anything about her suicide attempt, so Scottie tells her that she appeared to have slipped. As they talk, they begin to fall in love. But when Scottie leaves her to answer the phone, Madeleine slips out the door and flees. The next day, Scottie is surprised to trail Madeleine back to his own apartment, where she is leaving a thank you note for him. They decide to spend the day wandering together, traveling to the giant sequoia forest at Big Basin, where Madeleine makes evasive allusions to her possession and her strange dreams about death. She describes a place in her dreams that looks like Spain, which Scottie later recognizes to be the mission at San Juan Bautista.

Scottie tells Madeleine that he can explain her strange obsessions as a repressed memory of time she must have spent at the mission. He resolves to take her to the spot to bring to rest the notion that she is possessed. When they arrive, she recognizes it all, and after professing her love for Scottie, runs agitatedly toward the bell tower. She heads up the spiral staircase with Scottie in hot pursuit. Near the top of the tower, Scottie’s acrophobia strikes, and he is unable to continue the climb. He looks out the window in time to see Madeleine’s body hurtle down to the rooftop of an adjoining building. Scottie flees. He is next seen at the coroner’s inquest, where Gavin Elster is cleared of all responsibility for his wife’s death, but where Scottie is berated by the coroner for allowing his phobia to, in effect, cause the death of an innocent person. Wracked with guilt and grief, Scottie spends the next year catatonic in a sanatorium, where Midge attempts to bring him back to reality.

After his release from the sanatorium, Scottie again wanders the streets of San Francisco, seeing hints of Madeleine in everyone. He follows one woman, who he believes looks like a brunette Madeleine, back to her apartment and questions her relentlessly about her identity. She says her name is Judy Barton, that she hails from Kansas, and that she works in a department store. Scottie invites her to dinner. As soon as he leaves to allow her to change her clothes, Judy begins to pack a suitcase. Hesitating about what to do, she sits down and composes a letter to Scottie. In it, she divulges that she had been hired by Gavin Elster to play the role of Madeleine in a plot to murder his wife. Judy reveals that when she got to the top of the bell tower, Elster was waiting with the already-dead body of his wife dressed identically to Judy, which he hurled out the window for Scottie to witness. She ends her letter by admitting her love for Scottie. After a brief hesitation, she tears up the letter.

Scottie and Judy have dinner and it is apparent that Scottie is interested in Judy only insofar as she resembles the dead Madeleine. His obsession deepens, and he insists that Judy dye her hair blonde and wear clothing identical to that worn by Madeleine. Judy initially resists, but then decides she would rather be loved by Scottie as someone else than lose his love altogether. When she returns from the beauty parlor, her transformation is complete. They kiss passionately. In the next scene, the two are preparing to go to dinner when Scottie notices that the necklace Judy puts on is Carlotta’s necklace, which Madeleine wore the day she died. He realizes Judy’s true identity but does not say anything right away.

Instead, Scottie tells her he wants to take a drive in the country and begins driving toward San Juan Bautista. Judy becomes increasingly hysterical as she realizes that Scottie suspects her secret. In a rage, Scottie drags Judy up the steps of the tower, confronting her with her deception. She admits her guilt but claims to still love Scottie and begs for his forgiveness. They reach the top and embrace, but are interrupted by the shadowy figure of a nun. Judy is so startled by the ghostly figure that she screams and falls from the tower to her death. Scottie is left alone in the tower, cured of his acrophobia but broken in every other respect.