A few months after the previous film. Peter Parker plans to propose to Mary Jane Watson, who has made her Broadway musical debut. As they celebrate in Central Park, a meteorite crashes nearby and a black substance attaches itself to Peter's moped. After visiting with Aunt May, Peter is attacked by Harry Osborn, who has become the next Goblin. In the resulting struggle across New York, Harry suffers a head injury that erases his short-term memory, including his knowledge of Spider-Man and the Green Goblin.
After visiting his wife and daughter, who suffers from an unknown illness, escaped convict Flint Marko flees from police. During the chase, he falls into a particle accelerator that fuses his DNA with sand, transforming him into Sandman. After Peter saves Gwen Stacy, his lab partner, from falling to her death, she hosts a festival honoring Spider-Man. He kisses her at the urging of the crowd, which creates further tension with Mary Jane, who was fired after poor reviews and finds it increasingly difficult to accept Peter's double life. The festival is interrupted by Sandman, who robs an armored car and escapes despite Peter's efforts to stop him.
That night, Gwen runs into Peter and Mary Jane at dinner and Mary Jane walks out after confronting Peter about the kiss. Peter's feelings suffer further turmoil when Captain George Stacy informs him and Aunt May that Uncle Ben's presumed killer, Dennis Carradine, was only an accomplice to the real killer, Flint Marko. Peter's vengeful anger pushes Mary Jane further away. As he sleeps, the alien substance forms a black costume around Peter, who wakes up hanging from a skyscraper with his powers increased. He locates Sandman in a subway tunnel and seemingly drowns him. The next day, Mary Jane goes to Harry for solace and ends up kissing him. After she leaves in distress, his memories return and he coerces her into breaking up with Peter, to whom she says there's another man. Harry claims to be the other man when he meets with Peter. Later, Peter dons the black costume and fights Harry, whose face is disfigured when his pumpkin bomb is slung back at him.
Peter begins regularly wearing the costume, identified as a symbiote by Dr. Connors. He has Eddie Brock, his rival at the Daily Bugle, fired for submitting doctored photos depicting Spider-Man as a criminal. To make Mary Jane jealous, he brings Gwen, Brock's love interest, to the club where Mary Jane works, which is seen by Brock. After Gwen catches on and leaves, Peter fights with the bouncers and lashes out at Mary Jane when she tries to stop him. Realizing the symbiote is corrupting him, Peter retreats to a church bell tower and tries to remove it. Brock hears the bell and sees Peter overhead. The symbiote falls on Brock, transforming him into Venom. He finds Sandman, who survived the drowning, and joins forces with him.
The next night, Mary Jane is kidnapped by Brock and suspended in a taxicab from a web above a sand-filled construction site. Peter seeks Harry's help but is rejected. He arrives to save Mary Jane but is overwhelmed by Venom and Sandman until Harry, whose butler reveals the truth about his father's death, arrives to help him. Harry subdues the gigantic Sandman as Peter saves Mary Jane from falling. Harry moves to save Peter from Venom, who webs Harry's glider and sends him crashing into steel pipes, the sound of which weakens the symbiote the way the church bell had before. Venom tries to impale Peter with Harry's glider, but Harry jumps in the way and is mortally wounded. Peter uses the pipes to weaken the symbiote and free Brock. He throws a pumpkin bomb at it, but Brock is killed as well when he jumps at it.
Sandman reveals the truth about Ben's death: his gun discharged when Carradine grabbed his arm. The death has haunted him ever since. Peter forgives him and and he dissolves into sand and floats away. Peter and Harry forgive each other as Harry dies with Peter and Mary Jane at his side. A few days later, Peter, Mary Jane and Aunt May attend Harry's funeral. A short time later, Peter vists the jazz club where Mary Jane is singing. The two embrace and restart their relationship.