JERUSALEM – The elaborate machinery of a prisoner swap between two bitter enemies swung into motion early today, as more than 1,000 Palestinians and one Israeli soldier prepared to return home.

Before dawn, the first 96 Palestinian inmates were moved from a prison in the south to another in the West Bank, where they were later to be released, a spokesman for Israel’s Prisons Service said.

The Israel-Hamas deal is going ahead despite criticism and court appeals in Israel against the release of 1,027 Palestinians for a single captured Armored Corps sergeant, Gilad Schalit, held by militants in Gaza since 2006.

The exchange, negotiated through mediators because Israel and Hamas will not talk directly to each other, involves a delicate series of staged releases, each one triggering the next.

When it is over, Schalit – 19 years old at the time of his capture and 25 now – will be free, ending what for Israel has been a prolonged and painful saga. Israel was forced to acknowledge that it had no way of rescuing Schalit in a military operation, though the soldier was held no more than a few miles from its border.

Instead, Israel agreed to a lopsided prisoner exchange that Hamas officials have openly said will encourage them to capture more soldiers.