In North Africa, MacGyver is helping a local church repair their organ after an earthquake. A British woman, Sara Ashford, arrives with some supplies and asks MacGyver to help her. Her brother Brian is in a maximum-security military prison, convicted after bringing in a valuable bunch of supplies. Brian hid the supplies so the government couldn't get them. MacGyver agrees to help despite Sara's warnings that it could be dangerous, then picks a fight with the local soldiers who are harassing an elderly merchant. He sprays them with carbonated water, and they take him away.
Once he's brought in, the warden tells MacGyver the facts of life: he has no hope and will have to earn money or find a protector in the prison. François, a trustee, takes MacGyver away. When MacGyver tells him he was protecting an old man, François is impressed and commiserates. In the yard, MacGyver notices one well-appointed prisoner, Khan, and François warns him that Khan runs the place and his bodyguard, Fuad, has killed five men with his bare hands. Khan notices MacGvyer and tells Fuad to check on him, figuring he's either a drug dealer, a soldier of fortune, or a madman.
François, a Frenchman, takes MacGyver to his own quarters and admits he looks forward to talking with a fellow foreigner. MacGyver borrows François' soccer ball, uses newspapers to make a crude balloon using the sphere as a guiding shape, then ignites cotton balls soaked in olive oil to propel it into the air. Sara, waiting outside the prison, sees his signal. MacGyver invites François to come with him, but the Frenchman admits that he will be released in a few months and doesn't want to endanger his chances. He agrees to help MacGyver, though, and informs him that Brian is locked up with the political prisoners.
Fuad attacks MacGyver without provocation and subdues him after a brief fight. Khan has MacGyver brought to his personal quarters. MacGyver repairs his stereo system for him, then says he knows that Khan is manufacturing PCP. He offers to double Khan's output using his personal formula in return for a half-hour with Brian. Khan agrees and has MacGyver taken to Brian's cell. MacGyver figures that the commandant has the cell bugged. He talks about a gunship assault while writing a message on his palm in chalk telling Brian to play along. The Commandant tells Khan to play along until they can figure out where the money Brian hid is located, then dispose of them both.
That night, François admits it's nice to have a friend, but still refuses to accompany MacGyver on his escape. The guards arrive to take MacGyver to his visitor: his wife. Sara is waiting for him, and they fake a romantic embrace for the benefit of the hidden mikes. They then stage a conversation about the gunship assault set for noon the next day.
MacGyver meets with Khan the next day and secretly borrows a tape player. Khan takes MacGyver into his crude PCP laboratory and leaves him alone, and MacGyver starts to put together a plan. Khan reports to the Commandant, who reminds the prisoner of who's in charge and then stations men on the roof and orders the guards to the
MacGyver attaches a spatula to a ceiling fan and records the resulting noise. He then makes explosives out of PCP and stores it in a jacket, and then rigs ice in a metal basin to use as a timed fuse to set off the PCP with an electrical charge. Meanwhile, François delivers food to Brian's guard. MacGyver leaves, and Khan stops him, then demands the plan to free Brian.
Outside the prison, Sara arrives in a borrowed taxi and fakes engine problems. The guards watch her.
In the prison, MacGyver slips the tape player to François. He then claims that the escape plans are hidden under a fire. He borrows Faud's knife and starts digging. François sneaks into the Commandant's office and hooks up the timed tape player to the PA system. He then goes to the political wing and delivers the jacket with the PCP to Brian. At noon, the tape player activates and the guards think the gunship assault is on its way. Brian uses the PCP explosive in the jacket to blast open his cell door, and François leads him out. The ice in the lab activates the explosive, and Sara pulls up to the gates. Brian runs to his sister's car, while François finds MacGyver and wishes him well. MacGyver gets to the taxi and escapes with Brian and Sara. The Commandant warns Khan that he'll pay for his failure.
Sara pulls the taxi over and shoots out the engine, then points her gun at MacGyver. He realizes he's been tricked, and Sara explains that she's a Soviet agent delivering weapons to Russia's third-world allies. Brian was her supplier, a crooked arms dealer who stole her weapons but was arrested by the local authorities. He offered to give her the weapons back if she got him out of prison, so she tricked MacGyver into engineering the escape. She tells Brian to take her to the weapons, but he manages to escape. An angry MacGyver confronts her and she says that if she doesn't get the weapons, Brian will sell them to terrorists. Sara insists that she cares if the weapons are used on civilians and MacGyver agrees to help.
As they search the harbor for Brian's car, MacGyver agrees to help as long as they destroy the weapons when they find them. Sara agrees, and they find the car. Meanwhile, Brian meets with his satisfied buyers. MacGyver slips into the warehouse while Sara gets the car. He removes gunpowder from the grenades and sets down a powder line as a fuse to set off the weapons. He then throws a rock and yells "grenade!" As the terrorists scatter, MacGyver takes their briefcase of money and leaves with Sara. The grenades go up, covering their escape and destroying the weapons.
Later, MacGyver completes the construction of a new jungle gym for the mission children. Sara and MacGyver give Sister Ann the terrorists' money.