The film opens with a documentary-style series of interviews that introduce the situation. Twenty years before, an alien ship is seen coming towards Earth and arrives above Johannesburg, South Africa. It hovers above the city for three months without any contact; eventually humans take the initiative and cut into the ship. They discover a large group of aliens who are malnourished and sick. The aliens are later assessed as apparently being all “workers”, with their leadership mysteriously missing (it is hypothesized that a plague may have wiped out all of the leadership-caste). Grainy footage shows part of the ship (supposed to be a command module) falling to Earth, but nobody has been able to find it, leaving the ship inoperable.
The creatures, called “prawns” as a derogatory reference to the sea creature which they resemble, are housed in a government camp. The alien race’s true name is never learned; they are primarily referred to as “prawns” or, more rarely, “non-humans”. Overcrowding and militarization eventually turn the area into a slum known as District 9. A massive black market is set up between the aliens and a group of Nigerians primarily led by Mumbo, a paralyzed warlord. In addition to inter-species prostitution, the Nigerians exchange canned cat food for alien weapons, of which the cat food has a similar effect to catnip on the aliens.
The movie takes place in 2010. Patience over the alien situation has run out and control over them has been contracted to Multi-National United (MNU), a private company that shows little regard for the aliens’ welfare. MNU is interested in using the aliens’ advanced weaponry, but its integration with alien biology makes it useless for humans.
An MNU field operative named Wikus van der Merwe (Sharlto Copley), is set with a task to move 1.8 million aliens to a new District 10 camp located 240 km from Johannesburg, with help from private security forces working for MNU. While inspecting a suspicious alien residence, Wikus handles an alien device which squirts a dark liquid into his face. He becomes very sick and collects the device as evidence.
A rapid transformation begins to occur, and shortly after exposure to the liquid, Wikus’s left arm mutates into a claw exactly like that of a prawn. After collapsing at a surprise party in his house, and a doctor at a local hospital discovers his alien left arm, Wikus is taken into custody and a series of tests and experiments are performed on him; these reveal that his alien DNA allows him to operate alien weapons. The scientists discover that his DNA is currently “in balance” with the alien DNA, which is gradually taking over. They decide to harvest his body for biological material at this critical point, to have the greatest chance of replicating his ability to use alien technology in other humans later. To reduce any side-effects, no anesthetic was used. However, during the attempted vivisection Wikus escapes after overpowering his captors, and flees from MNU.
Wikus seeks refuge in the run-down shack of an alien called Christopher Johnson, who has a small son, the same alien who Wikus attempted to evict earlier, who created the alien device that infected Wikus. The device contains fuel that Christopher scavenged from various alien parts scattered around District 9. It is hinted that Christopher might be a surviving member of the prawn leadership caste, as he shows much more knowledge of how alien technology works, possesses or at least found the command module, and interacts with MNU officials more articulately than other aliens. Although initially hostile towards Wikus, Christopher eventually agrees to help him reverse the transformation if Wikus will retrieve the fuel from MNU labs. Christopher promises to undo the mutation by getting Wikus aboard the mother ship hovering over Johannesburg, and shows Wikus the ship’s command module, which has been hidden under his shack.
Wikus steals some alien weaponry from Mumbo and his gang, with Mumbo vowing to capture Wikus and eat his mutated arm (his witch doctor believes this will give him the power to operate the alien weaponry). With Christopher’s help they launch an assault on MNU and successfully retrieve the fuel sample. While there, Christopher discovers that MNU has been experimenting on his people. Wikus and Christopher fight their way back to District 9 and Christopher begins preparations to leave. He tells Wikus that he must first return to his home world to seek help for his people before he can cure Wikus. Furious, Wikus knocks Christopher unconscious and powers up the ship himself. The MNU mercenaries target Wikus and destroy one of the command module’s engines, causing it to crash land inside District 9.
After Wikus is captured by MNU, a battle between the MNU mercenaries and Mumbo’s gang breaks out. After a protracted firefight, the Nigerians capture Wikus. Just before Wikus’ arm is chopped off, Christopher’s son activates several systems in the mothership, including the autopilot routine of a mechanized battle suit; it slaughters Mumbo and his men after they fire on it. Wikus enters the alien walker battle suit, and after initially attempting to flee, returns and rescues Christopher. Armed with a lightning cannon, tracking missiles, and a high-powered machine gun, Wikus begins to fight the MNU men. After being knocked over by a anti-tank sniper round, he convinces Christopher to return to the shuttle without him, over Christopher’s objections. Christopher promises Wikus that he will return in three years to repair his body. Christopher then boards the shuttle and activates a tractor beam which returns the command module to the mother ship.
Wikus is shot in the back and the walker suit ejects him. Wikus, heavily wounded, begins dragging himself away from the leader (and sole survivor) of an MNU squad, but is quickly caught. As Wikus prepares to die, aliens burst out of the surrounding slums and dismember the mercenary.
The film concludes with another series of interviews and news broadcasts, providing human opinions on the events that unfolded. The aliens are successfully moved to District 10, which now has a population of 2.5 million and is growing. One of Wikus’ coworkers hacks MNU’s database and publicly exposes their illegal genetic experiments. There are many differing theories on Wikus’ fate. Some people believe that he either left on the mother ship, is in hiding, was captured by MNU or a government agency. Some interviewees hypothesize that the aliens are planning to return with a full army and declare war on humanity. An interview with Wikus’ wife reveals a small metal rose was left on her doorstep (Wikus has earlier demonstrated his affection with handmade gifts). Her friends have told her that it could not have possibly been Wikus, but she appears unsure. In the final scene, an alien with a bandaged left arm is shown in a junk yard fashioning a rose out of scrap metal.