Four lifelong friends - Doug MacRay (Ben Affleck), James "Jem" Coughlin (Jeremy Renner), Albert "Gloansy" Magloan (Slaine), and Desmond "Dez" Elden (Owen Burke), from the dangerous streets of Charlestown, a neighborhood in Boston, Massachusetts, are seen planning for a bank robbery, on the Cambridge Merchants Bank in Harvard Square. They wait until an armored courier making a dropoff enters the bank, then they climb out of a city utilities van, wearing skull masks to avoid identification. They overpower the guard and rob the bank. During the robbery, they take numerous extra precautions - Dez destroys the security tapes by putting them in a microwave in the break room, while Gloansy puts all of the hostages' cell phones in a fish bowl that he fills with water, and Doug makes sure to toss any wads of money containing dye packs. They also take an assistant branch manager, Claire Keesey (Rebecca Hall) hostage in their van. They dump her on a beach, unharmed.
FBI Special Agent Adam Frawley (Jon Hamm) and his partner Dino Ciampa (Titus Welliver) investigate the bank robbery. Dino notes that the robbers boosted a city work van, which hasn't yet been reported stolen. He notes that the van was used to screen the front doors. They are called away when Frawley receives a text, indicating that the getaway van has been discovered, torched. As firefighters extinguish the remains of the getaway van, Frawley and Dino observe the scene and conclude that they are dealing with a band of new professionals.
Doug follows Claire to prevent Jem from eliminating her as a witness, but they quickly begin a relationship. As they grow closer, Doug tells Claire of his search for his long-lost mother, and how he imagined she went to live with his aunt in Florida. He also blew a chance to be a professional hockey player for a life of crime. She tells Doug about seeing a tattoo on one of the men (Jem), and he realizes she can identify Jem and send them all to jail. He knows that Jem will kill her if he realizes the truth, and he persuades her that the authorities cannot protect her either so she decides not to tell the police. But Doug is increasingly disenchanted with his criminal lifestyle and the lies he has to tell.
Frawley and Dino surveil the gang, catching on to them after discovering that Dez, a Vericom cable company electrician, reported sick days on the days of several bank robberies, and discover their ties to local crime lord Fergus "Fergie" Colm, who has another robbery planned for them.
Doug is hesitant to undertake their next assignment, an armored car robbery in the North End. The gang takes every precaution before the robbery, including showering and scrubbing extensively to get rid of any loose skin, and even meticulously wiping down every piece of ammunition. Gloansy drives Doug and Jem in a Dodge Grand Caravan to the location of the ambush, outside a bank at Parmenter and Salem Streets. Unfortunately, the armored truck is running late so they are forced to drive around the block. When they see the car pulling up, Gloansy tells Doug and Jem to "say your prayers," and the three robbers put on rubber nun masks, complete with veils. A little boy on the street stares, petrified, as he catches a glimpse of Doug and his submachine gun.
Approaching the corner, Gloansy brings the van to a hard right and screeches to a halt next to the truck. Doug and Jem jump out and overpower the courier. Jem jumps into the back of the armored truck and begins loading money into a duffel bag while Doug shoves the dolly over to the van. As they load the money, Gloansy overhears the robbery call going on the police scanner and calls this out to Doug and Jem. Jem looks up, and notices that the truck driver is not in his seat. He turns and sees the driver on the street, jamming his pistol into Doug's back. Jem fires a burst that brings down the driver, freeing Doug. They jump into the van, and Gloansy speeds away.
Barely have they gone a few blocks when they are spotted by a police car. A wild car chase pursues through the narrow streets of the North End. Through abrupt moves, the robbers are able to throw off a few of the cruisers, which collide with other cars, but two of the police cars manage to catch up to them and stop the robbers' van using the PIT maneuver. One of the officers gets on his megaphone and orders them to climb out of their van. Jem, sitting in the backseat, raises his submachine gun and fires through the windshield, destroying the cruisers' engine blocks and sending the officers scrambling for cover. Doug leans out the side window and shoots up another police car, then the van drives away, pursued by several more cruisers. After a few more turns, they are driving down a hill when a Jeep Grand Cherokee pulls in front of them and cuts them off - Dez, driving the switch car. Doug, Jem, and Gloansy move their bags from their van to the switch car, with Jem laying down a base of fire to hold off the cops that have stopped behind them. Doug also tosses a match into the back of the van to gut the interior, and they drive away in the switch car. Weaving through traffic at high speed, with Gloansy driving, they manage to make it across the Charlestown Bridge before the police can block it. They reach the second switch car, and begin transferring their equipment to this car, but just as they are getting out, they see something that makes them stop dead in their tracks: a police officer sitting in his car across the street, looking at them, and obviously aware of who they are. After a few tense moments, the cop turns his head away, and the four robbers continue on their way.
Frawley has Doug, Jem, Gloansy and Dez brought in for questioning. However, all four men prove smart and outwit Frawley, who is forced to release them when he fails to bring up any confessions.
During a visit to his father (Chris Cooper) at the local federal prison, Doug reveals he is planning to leave Charlestown. Jem approaches Doug with another job, but he turns it down. He tells Fergie he will not do the job, but Fergie reveals that Doug's mother never left the family. She committed suicide after Fergie got her addicted to drugs in retaliation for Doug's father attempting to also leave and warns that he will kill Claire if Doug does not do the job. Doug finally agrees.
Doug and Jem enter Fenway Park dressed as Boston police officers, wearing sunglasses to hide their identitites, while Dez deactivates the security system. Doug and Jem approach the guards near the cash room and pretend to be responding to a 911 call, then draw Glock 17s on the guards and force them to the ground, zip-tying their hands behind their backs. They then threaten the men in the cash room to get him to let them in. After securing these men, they load $3 million into their duffel bags and head over to their getaway vehicle, an ambulance parked in the garage, where they meet Gloansy and Dez and change into paramedic uniforms. Unfortunately, they sense that it is too quiet, look outside, and see that the police are taking up positions outside. When Jem spots an FBI SWAT team in the garage, he opens fire on them. A shootout erupts, and in the process, several SWAT officers in the garage are wounded, and Dez is killed when he is deafened by a flash grenade (Doug, Jem and Gloansy cover their ears) and then shot by a SWAT officer. Gloansy offers to sacrifice himself to protect Doug and Jem, gets into the ambulance, and bursts out of the parking garage. The police fire on the van, hitting Gloansy at least twice, and the ambulance crashes into a mobile command center. As the cops move in on the ambulance, Doug and Jem in the garage put on their cop uniforms, blending in with the BPD officers as they move in, and they go separate ways.
Frawley figures out the ruse when he overhears a police captain talking to Dino about how the robbery was committed by two cops. He scans the officers on the scene, then he and Dino drive slowly through the area near Fenway Park, spotting one cop walking away from the action carrying a duffel bag. It is Jem. Frawley follows Jem into a parking lot, repeatedly calling out to him. At this same time, Doug comes out another door. When Frawley calls out to Jem by his real name, Jem turns around and opens fire on Frawley with a TEC-9. He chases Frawley around a car, and then runs towards Boyleston Street, as Frawley fires at him with a shotgun. Jem reaches the street just as police arrive to intercept him. He takes his last stand, firing on the cops with his TEC-9 and Glock 17, bringing down a few of them. Jem falls when a blast from Frawley's shotgun hits him in the leg and he crouches behind a mailbox. As Frawley yells for Jem to surrender, Jem then empties his pistols, and enjoys a last sip from a discarded soda nearby. Determined not to go back to prison, he gets back up with his guns drawn, which provokes the police into gunning him down. Doug looks on, shocked, and escapes unnoticed by stealing a police car.
Doug drives the cruiser over to Fergie's shop, where he shoots Fergie's bodyguard in the head at point-blank range, wounds Fergie after a close-range gunfight, and finally finishes him off with a shot to the groin. He calls Claire and asks her to come away with him, but he is watching from a house nearby and can see the FBI are in the same room with her. Claire, at first tells him to come to the room to pick her up, but in the end gives him a coded message to warn him that the FBI are there. Doug puts on an MBTA bus driver's uniform, makes his way to an Amtrak station, and boards a train heading south. Later, Claire finds a bag buried in a community garden which she tends. The bag contains money, a tangerine and a note that ends with "I'll see you again, on this side or the other." Claire uses the money to finance the renovation of a local hockey rink, and dedicates it to Doug's mother.