The film opens with five British soldiers walking through the empty streets of Dunkirk across the English Channel from Britain in France. They, along with over 400,000 British and French soldiers, are trapped in a French city, which is surrounded by the German forces. Suddenly, unseen German soldiers open fire, and only one Allied soldier survives, a boy named Tommy, who manages to escape and to reach the beach where other soldiers await evacuation.
The beach is not safe either, as German planes fly over the beach and drops bombs on the soldiers gathered there, killing many of them. As a result, the beaches are littered with the bodies of dead soldiers, left there to rot.
Seeing a stretcher on the sand, Tommy and another soldier named Gibson take it and pretend to be medics so they can get on the boat. When they are turned away from the rescue destroyer, the two soldiers hide on the mole, determined to wait for the next ship to come.
While hiding, they overhear a conversation between Commander Bolton and Colonel Winnant talking about the soldiers on the beach, the fact that there are not enough evacuation vehicles, and the safety of the mole.
After the conversation, German planes began to bomb the ship while it is still at the dock, as well as the mole itself. The soldiers on the ship jump off to survive, and Tommy and Gibson are joined on the mole by a soldier named Alex. The three soldiers then quickly board a bigger vessel that is supposed to take them to England. Gibson stays above deck, watching as the ship is hit by a torpedo. Gibson opens a trap door from the outside, and Alex and Tommy are able to escape the sinking ship.
The situation becomes tenser as the Germans push the French and the British even closer to the water. Alex, Tommy and Gibson join a group of soldiers going towards a grounded trawler, and hope that once the tide comes in, they will be able to navigate the boat back to England. On the trawler, Alex becomes suspicious of Gibson, who has not spoken since they met, and Gibson eventually reveals that he is French. After Germans start shooting at the boat, the boat begins to flood with water and the soldiers must escape. When Gibson gets his foot caught, he is taken down with the sunken trawler and dies.
A huge group of civilian boats approach Dunkirk, there to help the trapped soldiers escape. Mr. Dawson, a civilian, takes his boat Moonstone, along with his son, Peter and Peter's friend, George. On the water, they discover a soldier on the wreckage of a sunken British ship and take him with them. The soldier is unresponsive and he becomes violent when Mr. Dawson tells him that they are headed towards Dunkirk. Mr. Dawson convinces the soldier to go below deck and Pete locks him in a room to calm him down. He manages to get out and when he sees that the ship is going towards Dunkirk, he becomes even more unstable, struggling with them and knocking George down a flight of stairs. George hits his head and is in critical condition, eventually dying.
Dawson and Peter then spot a British plane plunging into the water and they arrive just in time to save the pilot inside it, Collins. With Collins' help, they rescue a number of soldiers.
Meanwhile, another pilot in Collins' squadron, Farrier, is working on shooting down German planes when he runs out of fuel. He lands on a beach, after shooting down more German planes and helping the British cause, but when he lands he is apprehended by German troops.
The film ends with the British soldiers returning home and Captain Bolton deciding to remain at Dunkirk to help the French evacuate. Tommy reads the front page of the newspaper, in which he discovers that the soldiers from Dunkirk are being praised as heroes. The viewer also finds that while initially Churchill thought that they could save only 30,000 soldiers, the civilian boats saved more than 338,000 British soldiers from Dunkirk.