Eight years later, Valjean has become a factory owner and mayor of Montreuil-sur-Mer. Fantine (Anne Hathaway), one of his workers, is discovered to be sending money to her illegitimate daughter, Cosette (Isabelle Allen), who lives with the unscrupulous Thénardiers (Helena Bonham Carter and Sacha Baron Cohen) and their daughter Éponine (Natalya Angel Wallace), and is dismissed by the foreman. In a desperate attempt to support her daughter, Fantine becomes a prostitute. She is arrested by Javert after she attacks an abusive man, but is saved by Valjean, who has her hospitalised. Later, Valjean learns that a man believed to be him has been arrested. Unable to accept that an innocent man is condemned in his place, Valjean reveals his identity to the court at the man's trial. Returning to the hospital, he promises a dying Fantine that he will look after her daughter. Javert arrives to take Valjean into custody, but after a brief confrontation, Valjean jumps into a river to escape. He pays the Thénardiers to allow him to take Cosette, and promises to be like a father to her. They elude Javert's pursuit and begin a new life in Paris.
Nine years later, Jean Maximilien Lamarque, the only government official sympathetic toward the poor, is nearing death. Students Marius Pontmercy (Eddie Redmayne) and Enjolras (Aaron Tveit), together with street urchin Gavroche (Daniel Huttlestone), discuss revolution. Marius later catches a glimpse of Cosette (Amanda Seyfried), now a young woman, and instantly falls in love with her. Meanwhile, despite Cosette's questioning, Valjean refuses to talk about his past or her mother.
At a café, Enjolras organises a group of idealistic students as Lamarque's death is announced. Meanwhile, Éponine (Samantha Barks), Marius's friend, leads him to Cosette, where the two profess their love for one another. Lamenting that her secret love for Marius will never be reciprocated, Éponine fatalistically decides to join the revolution. When a gang led by Thénardier attempts to capture Valjean for ransom from Javert, Éponine screams to warn Valjean and Cosette; Valjean decides to flee, unaware of Cosette's desire for Marius. As they leave, Enjolras rallies the Parisians to revolt, and Marius sends a farewell letter to Cosette. The next day, the students interrupt Lamarque's funeral procession and begin their revolt. Javert poses as a rebel in order to spy on them, but is quickly exposed by Gavroche and captured. During the ensuing gunfight, Éponine saves Marius at the cost of her own life, professing her love to him before she dies in his arms. Valjean, intercepting the letter from Marius to Cosette, goes to the barricade to protect Marius. After saving Enjolras from snipers, he is allowed to execute Javert. However, when the two are alone, Valjean frees Javert, telling him to run as he shoots his rifle at a wall to convince the students he killed him.
With the Parisians not joining the revolution as the students expected, they resolve to fight to the death. Everyone is killed but Marius, who is saved when Valjean drags his unconscious body into the sewers. Thénardier, scavenging the dead bodies, steals Marius's ring. Valjean recovers and escapes the sewers carrying Marius, but is confronted at the exit by Javert. Valjean begs for one last hour to take Marius to a doctor; Javert initially refuses and threatens to shoot him if he does not give up. Valjean ignores him and is allowed to leave to save Marius. Unable to reconcile the conflict between his civil and moral duties, two things which he always considered the same, Javert jumps to his death into the Seine.
Later, Marius mourns for his friends but Cosette comforts him. Revealing his past to Marius, Valjean tells him he must leave because his presence endangers Cosette, and makes Marius promise never to tell her. Marius and Cosette marry; the Thénardiers crash the reception and testify that they saw Valjean carrying a murdered corpse through the sewers. Thénardier unwittingly shows Marius the ring that he stole from him as "proof." Recognising the ring, Marius realises that it was Valjean who saved his life. Being told Valjean's location by Thénardier, Marius and Cosette depart to find him.
As Valjean sits dying in a local convent, he perceives the spirit of Fantine appearing to take him to Heaven. Cosette and Marius rush in to bid farewell. Valjean hands Cosette his confession of his past life, and joins the spirits of Fantine, the Bishop, Enjolras, Éponine, Gavroche, and the other rebels at the barricade.