John Hancock is an alcoholic who possesses superpowers, including flight, invulnerability, and superhuman strength. While performing superhero-like acts in Los Angeles, he is often ridiculed and hated by the public for his drunken and careless acts, and becomes enraged when referred to as an "asshole." Hancock rescues Ray Embrey, a public relations specialist, from an oncoming train, which he irrationally derails to save Ray. Thankful and seeing him as a career opportunity, Ray offers to help improve Hancock's public image. Hancock meets Ray's family, his son Aaron, who is a fan, and his wife Mary, who takes an immediate dislike to Hancock.
Ray encourages Hancock to issue a public apology, and then go to prison for a time, until Los Angeles needs him properly. Hancock reluctantly agrees, struggling to fit in prison, and quickly causes trouble when he assaults two fellow inmates that refuse to leave him alone. Hancock is visited by Ray's family, encouraging him to be patient. Los Angeles' crime rate rises, and Hancock is eventually released to help. He foils a bank robbery orchestrated by Red Parker, with Hancock slicing off his hand to prevent him from activating a detonation switch. He is praised as a hero, and becomes popular.
Hancock reveals to Ray and Mary that he is amnesiac and an immortal, having woken up in a hospital 80 years ago with no memory of his identity. He also learns Mary isn't Aaron's biological mother, and is Ray's second wife. Carrying a drunk Ray home, Hancock kisses Mary, only for her to toss him through the wall, revealing she has superpowers too. The next day, Hancock and Mary speak in private. Mary claims they have lived for three thousand years, are the last of their kind, and are siblings. Hancock disbelieves her about the last claim, and flies away to inform Ray, only for Mary to chase him and incite a violent battle across the city. Ray witnesses the fight, later confronting the duo. Mary admits Hancock is actually her husband from the past, but that she chose to quietly leave him once he had lost his memories of them.
That night, Hancock stops a liquor store robbery, only to be shot multiple times, and is hospitalized. Mary appears, explaining that when the immortals paired up, they would slowly lose their powers, becoming mortals. The last time Hancock and Mary were together was eighty years before, when Hancock was attacked; his amnesia is a result of the attack. Parker, who escaped prison with several other criminals, attacks the hospital to get revenge. Mary is caught in the crossfire and injured. Hancock recovers, killing the criminals, but is further injured. Parker tries to kill him, but Ray cuts off Parker's gun holding hand with a fire axe and kills him. Hancock throws himself out of the hospital, trying to increase his distance from Mary so that she can recover, before flying off towards the Moon.
A month later Ray and his family receive a call from Hancock, revealing he has imprinted the Moon's surface with Ray's AllHeart marketing logo. In a mid-credits scene, Hancock approaches a criminal in New York City, who calls him an "asshole" in a tight outfit, much to his fury.