He recruited Israeli and international activists to march every Friday with Bilin residents up to the fence, which is 14 feet high here. It protects a part of the sprawling Jewish settlement of Modiin Illit that was built on the village's land.
He made sure protesters carried video cameras to document the army's use of tear gas and rubber-coated bullets to keep them away. And he worked to enforce zero-tolerance of violence by the activists, failing to stop only the few teenagers who sling rocks and occasionally strike soldiers.
Michael Sfard, an Israeli lawyer retained by the village, credits Khatib with the "brilliant idea" that turned the tide in a landmark legal victory two years ago.
Under cover of darkness, Khatib led a clandestine construction crew across the barrier and built a makeshift hut on village land that had been usurped for a new neighborhood of the Jewish settlement. (The stealth maneuver mimicked Israel's expansionist strategy of creating "facts on the ground.")
When the army threatened to demolish the hut, the village went to Israel's Supreme Court and challenged the new neighborhood, which lacked formal government authorization. The court ordered Israel to stop building in the neighborhood, move the fence and restore about half the 575 acres of olive groves Bilin's farmers had lost.
Khatib then set up an alliance of 11 West Bank villages to share his strategies, and some have borne fruit. Six communities have successfully challenged the barrier's route across their land. Activists have linked up with outside supporters to sneak water trucks into parched communities cut off by the army and to protect olive harvesters from harassment by settlers.
But in Bilin, the legal victory gave way to setbacks.
The army has yet to comply with the ruling and move the barrier; the precise new route has been tied up in litigation. Meanwhile, soldiers began reacting with greater force to the protests, and most Israelis, who value the barrier as a shield against violence, remained indifferent.
In April, Khatib was standing a few feet away when a companion, Bassem Abu Rahma, was killed by a high-velocity tear gas grenade fired into a crowd of marchers.
Abu Rahma's death still haunts him. Twice, he says, soldiers have warned him that he'll "end up like Bassem" if he keeps resisting their presence in the West Bank.
Khatib and 27 other protest leaders and participants were arrested in their homes during the midnight raids that began in June. Seventeen are still being held. Khatib faces charges of inciting violence.
Asked to explain the crackdown, a battalion commander said protesters causing damage to the fence had been photographed and singled out for arrest. But after a week of requests, the army did not detail any damage claims.
On a recent Friday, the villagers had one visible impact on the fence, a Palestinian flag left hanging from barbed wire. After the marchers had gone home, a soldier tore it down, wiped his hands with it and stuffed it into a pocket.