When a militia group in the Pyrenees Mountains captures an American geologist, Dr. Andrea Gates, MacGyver volunteers to help. He sneaks into the camp, strips, and dons a towel so he can blend in with the soldiers using an outdoor shower. As he passes by, he kicks the shower's water pipe into the cooking fire. He then goes to the cabin where Gates is held and uses a log to lever the locked door up off of its hinges. Slipping inside, he and Gates put on soldier uniforms and MacGyver soaks a rope in gasoline.
When the heated water distracts the soldiers, MacGyver and Gates run for a nearby cliff over a river. They rappel down the rope and MacGyver sets it on fire to slow down the pursuing the soldiers. MacGyver grabs a coil of barbed wire and they take a rubber boat down river. The soldiers, coming down on their own ropes, pursue in another boat. MacGyver stops long enough to anchor the barbed wire to either side of the river. They continue on and the soldiers hit the barbed wire, deflating their boat and leaving them to flounder.
MacGyver goes to Brazil at the behest of his friend, ornithologist Dr. Charles Alden. Alden has noticed patterns of birds flying outside of their territory, apparently due to fear. MacGyver sets the two of them up with an expedition boat and they head upriver. They arrive at an outpost and try to recruit a guide, but the local commissioner, Santos, informs them that the natives refuse to travel into the jungle due to dreams of demons. MacGyver has heard of a local cocoa plantation owner, Lucien Trumbo, but Santos warns that Trumbo is a difficult man who refuses to permit any outsiders on his property and ignores the law.
MacGyver and Alden take a smaller boat and go past a local native sign in the shape of a mask. They approach a small dock and the natives open fire on them. Trumbo rides up and tells them that they're trespassing on his property. Alden tries to convince him that the situation with the birds is serious, but Trumbo isn't interested. MacGyver hears Trumbo's irrigation pump running erratically and suggests he take a look at it in return for a guide's services. Trumbo refuses to bargain and MacGyver offers to repair the pump anyway. After removing the broken piston, one of Trumbo's workers, Luiz, escorts MacGyver to the plantation house. Luiz explains that when his people were wiped out by an opposing tribe, Trumbo took him in and provided him with food and shelter. The American came to the jungle with nothing and carved a plantation out of the unforgiving land.
At the plantation, MacGyver is forced to improvise an electrical arc welder out of a car battery, jumper cables, and a pair of fifty-cent pieces. Trumbo is impressed but refuses to endanger his people. He admits he owes MacGyver and offers to guide them himself. The next morning, the three men move through the village and discover more birds and animals fleeing in terror. Coming out of the jungle on the way to a village, they see the cause of the animals' panic: a two-mile wide column of Marabunta: soldier ants. The ants are heading toward Trumbo's plantation and will go through the nearby village.
Hearing screams, the men investigate and find the village under attack by ants. A canoe falls on one woman, trapping her. MacGyver rigs a makeshift winch with rope and a pole and, with Trumbo's help, lifts the canoe off her legs. Meanwhile, Charlie goes to check out the ants on the far side of the village. He moves to the edge of a slope and starts taking photos. However, the ants start climbing on him. Panicking, he slips and falls down the slope into the ants, calling for help. By the time MacGyver and Trumbo get there, it's too late.
Trumbo and MacGyver return to the plantation where the workers have piled up branches around the walls of the main house. Despite MacGyver's warnings, Trumbo refuses to leave the plantation to the ants. When he hears that the workers are fleeing, Trumbo goes after them and tries to convince them to stay. An older worker warns that they know what the ants can do and there's no way to stop them. Furious, Trumbo shoots one of the canoes. MacGyver pulls him off his house and the two men struggle while the natives quickly row away. Only Luiz stays with Trumbo. An angry Trumbo insists he doesn't need anyone and rides off. Luiz explains that he is staying to defend his home and asks MacGyver why he's staying behind. MacGyver claims that he wants to see how his welding job holds up.
Back at the plantation, the men determine that the ants are going to hit the river then turn toward the plantation across the fields. MacGyver suggests they flood the irrigation ditches to repel the ants. As an alternative, MacGyver suggests fire and if that doesn't work, destroying the dam to flood the entire plantation. Luiz goes to the dam to flood the ditches while MacGyver hooks up a hose to Trumbo's fuel tank and creates a makeshift flamethrower. The ants get to the ditches and use leaves to float across. Luiz starts to raise the water level but the ants swarm over his position. He collapses trying to reach the control wheel. Trumbo and MacGyver realize the ants have broken through and Trumbo starts to go to Luiz. MacGyver warns him it's too late. At the dam, Luiz makes one final effort to raise the water level…and falls down dead.
MacGyver uses his flamethrower to ignite the branches piled up against the walls. The plan initially works and the ants are incinerated. However, the fuel runs out and a new wave of ants approach. MacGyver makes an explosive out of fertilizer, acid, and plant cellulose. He then creates a protective suit by melting rubber hoses, spreading the mixture on plastic sheets, and cutting the sheets to make a suit. MacGyver dons the suit and runs across the now-barren landscape. The ants cover him, making it difficult to see. He gets to the dam and is forced to remove his headpiece to see what he's doing. He manages to plant the explosive and runs away, covered with ants. The explosion goes off and the flood waters sweep over MacGyver and wipe out the ants.
Trumbo emerges from the plantation to find MacGyver, alive and well, washed up nearby. Trumbo thanks him for his help, noting he has more to work with then he did the first time. He asks MacGyver to return in a year to see what he's rebuilt.