John Hancock (Will Smith) is an alcoholic homeless man with superpowers (including flight, invulnerability, immortality, and superhuman strength). Though he uses his powers to stop criminals in his current city of residence (Los Angeles), his activity inadvertently causes millions of dollars in property damage due to his constant intoxication. As a result, he is routinely jeered at crime scenes. Hancock also ignores court subpoenas from the city of Los Angeles to address the property damage he has caused.
When public relations spokesperson Ray Embrey (Bateman) departs from an unsuccessful meeting pitching his All-Heart logo for corporations that are extraordinarily charitable, he becomes trapped on railroad tracks with an oncoming freight train. Hancock saves Ray's life, but he causes the train to derail and nearly injures another driver. Other drivers jeer at Hancock for causing more damage, but Ray steps in and thanks Hancock for saving his life. Looking to pay Hancock back, Ray offers to improve Hancock's public image, and Hancock grudgingly accepts. The spokesperson convinces the alcoholic superhero to permit himself to be jailed for outstanding subpoenas so they can show Los Angeles how much the city really needs Hancock. When the crime rate rises after Hancock's incarceration, the Chief of Police contacts the superhero. With a new costume from Ray, Hancock intervenes in a bank robbery, rescuing a cop and stopping the leader of the robbers, Red Parker (Marsan) by disarticulating his wrist.
After the rescue, Hancock is applauded for handling the bank robbery. The superhero becomes popular once more, as Ray had predicted. He goes out to dinner with Ray and his wife Mary (Theron), to whom he reveals his apparent immortality and his amnesia from 1931, about 80 years ago. After Hancock tucks a drunken Ray into bed, he discovers that Mary also has superhuman powers. He threatens to expose her until she explains their origins; she explains they have lived for 3,000 years with their powers, having been called gods and angels in their time. She adds that they are the last of their kind and all the others have died. When Hancock moves closer to Mary, stovetop popcorn begins to pop and Hancock questions what relationship they have. When Mary insists only bad things happen when they are near and they are brother and sister, Hancock suspects Mary is not telling the entire truth so he departs to tell Ray about the conversation. Mary flies off after him and tries to knock him from the sky. When they land in downtown Los Angeles, Mary tries to disappear into the crowd, but not before Hancock calls her crazy. This results in a battle between Hancock and Mary in downtown Los Angeles, causing significant damage to the area. Ray, downtown in a business meeting, sees and recognizes Mary using superhero powers like Hancock.
Ray goes home and Mary lands with Hancock arriving soon after. Ray immediately confronts Mary about her flying and abilities and Hancock expresses his desire to get answers as well. When Ray starts to object, Mary clarifies the relationship between her and Hancock is technically wife and husband; effectively voiding the marriage between her and Ray. Mary then explains their kind existed in pairs, but she has been trying to get away from him and is happier now that she has left him.
Discouraged, Hancock finds himself in a convenience store buying liquor. When the shopkeeper rings up two 1.75L bottles of liquor as $91.10, Hancock gets in an argument about the price being too high. The shopkeeper, being held at gunpoint unbeknownst to Hancock, has to physically cover the zero to get his message of distress across (9-1-1 is the emergency telephone number of North America). After tossing one robber aside, his partner grabs the shopkeeper and holds him as hostage. Hancock asks the robber to instead shoot him and, in turn, he will toss a candy bar at him. The robber shoots Hancock in the abdomen and the candy bar sends the robber through the front storefront window. Hancock casually apologizes to the shopkeeper for breaking his window. He goes into shock when he sees himself bleeding.
He is hospitalized, and Mary visits to explain that as the pair of immortals gets close, they begin to lose their powers. She also explains that Hancock's enemies have throughout history attempted to attack Hancock through Mary, and Hancock has spent his life protecting her. The evidence is on random scars across his body, proving he has become human in the past. Swordsmen have challenged him, and mobs have set fire to his home while she was inside. The last attack was in an alley in Miami, Florida almost 80 years prior, causing his amnesia. For some reason she was not allowed in the ambulance, and by the time she had arrived at the hospital, Hancock had already awoken and didn't recognize her. She then left him because she knew people would always come after them if they stayed together.
Soon after explaining herself to Hancock, the hospital is raided by Red Parker, the bank robber, and four other men. Mary, sitting between Hancock and the gang, is shot in the crossfire. Hancock is able to stop the four men but is further wounded by them. Mary can feel the pain he is experiencing which is much worse than being shot. As she tries to get to Hancock, medical workers stop her, as her powers have gone, and place her in four-point restraints. Through rage, Hancock still has his strength, although he can still be wounded. He gets stabbed in the upper shoulder and suffers more gunshot wounds. Hancock isn't able to disarm Red who shoots him several more times with a handgun. When Red attempts to finish Hancock off, Ray comes to Hancock's rescue by disarticulating Red's wrist. While stunned at losing his other hand, Ray kills the bank robber with another blow. With Mary's heart stopped, and Hancock unconscious, medical workers are desperately trying to save their lives to no avail. Suddenly, Hancock slowly awakens and forces himself to make his way down the hallway. As their distance apart grows, Mary's heartbeat slowly comes back, and Hancock is able to move without as much effort. When he reaches the window, he jumps from the six story hospital window into a busy intersection, crashing into several moving vehicles. Mary's heartbeat stabilizes as Hancock leaves the scene.
Hancock later winds up in New York City, working as a superhero. Ray is seen walking with Mary discussing historical events, such as the reign of Attila the Hun, in a jovial manner. Out of gratitude to Ray, Hancock paints Ray's All-Heart logo on the moon and calls the PR spokesperson to look up at the worldwide advertisement.