The Iron Giant

Shortly after the launch of Sputnik in October 1957, nine-year-old Hogarth Hughes of the fictional town of Rockwell, Maine spots a meteorite crash into a nearby forest. Investigating, he finds a giant robot being electrocuted as it tries to eat the transmission lines of an electrical substation. Hogarth turns off the station, and the robot runs off. Hogarth tracks down and befriends the robot, finding it docile and curious. When it tries to eat railroad tracks in the path of an oncoming train, Hogarth tries to have the robot repair the damage, but the train collides with its head and derails. Hogarth helps usher the robot away from the scene, discovering that its damaged parts are drawn to the robot and can undergo self-repair. Hogarth hides the robot in his family's barn. After dinner with his widowed mother Annie, Hogarth reads comics to the robot. The robot is impressed with the adventures of Superman, but is agitated by how the villainous "Atomo the Metal Menace" is depicted. Hogarth calms the robot by telling it "you are who you choose to be".
The recent incidents lead U.S. government agent Kent Mansley to town. He discovers evidence of Hogarth's involvement and rents a room in their house to stay close to the boy. Hogarth ditches Kent long enough to move the robot to a junkyard owned by beatnik artist Dean McCoppin, where they are able to pretend the robot is one of Dean's scrap metal sculptures. Nevertheless, the easily-spooked Kent issues orders for the military, led by General Kenneth Rogard, to move into town.
Hogarth enjoys his time with the robot but is forced to explain the nature of death when they witness hunters kill a deer. One day, Hogarth is playing with the robot using a toy gun. The robot involuntary reveals several powerful weapons, and Dean rescues Hogarth before one strikes him. The robot reverts to its docile form and Dean orders it away for Hogarth's safety, but Hogarth gives chase. Dean realizes the robot was acting in self-defense and quickly catches up to Hogarth as they follow the robot into town.
The robot saves two boys falling from a roof when it arrives, impressing the townspeople. Kent convinces Rogard to start an attack against the robot. The robot exposes its weapons again, and readily overpower the military. Dean and Hogarth arrive and they are able calm the robot down. However, the military continue to attack, and the robot moves to protect Hogarth. Hogarth is knocked unconscious but the robot, believing him to be dead, engages its weapons against the military. Kent convinces Rogard to prepare to launch a nuclear missile from the USS Nautilus offshore if they cannot stop it. Dean and Annie revive Hogarth, and the boy is able to calm the robot down to its docile state, while Dean explains the situation to the military. Rogard is ready to stand down when Kent panics and orders the missile to fire. As everyone looks on at the launch, Rogard furiously reminds Kent that the missile is locked onto the robot and they will all be killed in the blast radius. Kent tries to escape but the robot stops him and he is taken into custody. Hogarth explains to the robot what is about to happen. The robot says farewell to Hogarth and flies off to intercept the missile, stating "I'm Superman". The missile explodes harmlessly in the atmosphere. As the townspeople and military are relieved to be alive, Hogarth is saddened by his loss.
Some months later, the town has constructed a statue of the robot in its memory, and Dean and Annie are starting to see each other. Hogarth receives a package from General Rogard, a bolt from the robot being the only remnant they could find. That night, Hogarth sees the bolt trying to move on its own, and he opens the window, letting the bolt roll free. The bolt joins many other parts as they converge on the robot's head at the LangjÃ¶kull Glacier in Iceland. The robot's head activates, and it smiles.

Question: Who is the robot fighting against?
Answer: the military