The novel's main character is Robert Neville, apparently the sole survivor of a pandemic, the symptoms of which resemble vampirism. The author details Neville's daily life in Los Angeles, as he attempts to comprehend, research, and possibly cure the disease that killed mankind, and to which he is immune (Neville assumes this is because he was bitten by a vampire bat who was "infected". Because it was not a human, it did not kill Neville, instead, he became ill for a period of time). Neville's past is revealed through flashbacks, while his emotional struggle to cope with losing his humanity is dealt with by going about a daily routine.
Every day Neville prepares for nightly sieges from a vampire horde. Neville spends the daylight hours repairing his house: boarding windows, hanging garlic garlands, disposing of vampire corpses and gathering supplies. Once darkness falls, the infected come out of hiding and lay siege to Neville's house. They taunt him and attempt to entice him out — he recognizes one vampire as a former friend, Ben Cortman.
After bouts of depression and heavy drinking, Neville decides to find the cause of the disease. He obtains books and other research materials from a library, and through painstaking research he discovers the root of the vampiric disease: a strain of bacteria capable of infecting both deceased and living hosts. However, he does not realize that the living hosts (the infected) are still inherently human, even though they exhibit all the signs of vampirism.
Neville comes across the seemingly uninfected woman, Ruth, abroad in the daylight and captures her. After the initial shock of seeing another human wears off, Neville becomes suspicious of Ruth and is skeptical of her story. He also notices that she is strongly against the killing of the vampires — he feels that if her story of survival was true, she would have become hardened to their fate, nevertheless the two live in a wary state of tolerance. Eventually the two grow closer and one night Neville finds Ruth about to leave. Suspicious, he questions her motives, but ends up relating all of the trauma of his past to Ruth, who attempts to comfort him and the two make love. Afterwards Ruth agrees to let him take a blood test on her the following morning, she knocks him out just as he realizes she is infected. When he wakes up, Neville discovers a note left by Ruth. In it, she tells him that the infected have slowly been able to adapt to their disease to the point where they can spend short periods of time in sunlight and they are even attempting to rebuild society. They fear and hate Neville since he has unwittingly destroyed some of their people along with true vampires (dead bodies animated by the 'germ') during his daytime excursions and view him as a predator. In their quest to capture him, the infected sent one of their own to Neville. Ruth warns Neville in her note that her people will eventually attempt to capture him by force, and that he should leave his house and escape while he can. Neville disregards Ruth's warning, through not wishing to leave his house, and is eventually captured by an ambush party of mercenaries used by Ruth's society to kill any true vampires they encounter.
After his capture, Neville is held in a prison, awaiting execution, and is visited by Ruth; she informs him that she is a ranking member of this new society but unlike the others she doesn't fear and hate him. She tells him she had come to his prison to try and help him escape but that is now impossible. She acknowledges the need for Neville's execution, and slips him pills, claiming they will "make it easier." Emotionally broken, Neville finally accepts his fate and tearfully asks Ruth not to let this society get too brutal and heartless. Ruth kisses him and leaves.
Neville goes to his prison window and gets a glimpse of all the infected milling about in the yard waiting for his execution. When they spot him, he sees the fear, awe and horror in their eyes and he understands to them he is a scourge, just as they were a scourge to him at the beginning of the novel. Previously Neville saw the destruction of the infected survivors as a right and a moral imperative to be pursued for his own and mankind's survival, but now he finally acknowledges defeat. He is the only known immune human left in the world, the only survivor of the "old race".
He glimpses a future society where infection is normal and he, Neville, is a murderous biological deviant. As he turns away and swallows the pills, Neville grasps the reversal that has taken place and that just as vampires were legend in pre-infection times now he, an obsolete exemplar of old humanity, is legend in the eyes of the new race born of the infection. As his perspective shifts Neville is able to chuckle even as he dies, his last thoughts being "[I am] a new superstition entering the unassailable fortress of forever. I am legend."