The ordeal of Gilad Shalit has been a dramatic one.
He was captured early one Sunday morning in 2006, after Palestinian militants burrowed their way under the border from Gaza into Israel.
Two other Israeli soldiers and two attackers were killed in the firefight. Shalit was wounded when his tank was hit by a rocket-propelled grenade. The 19-year-old corporal was dragged back to Gaza, where he disappeared into the concrete maze of refugee settlements.
Of course, this ordeal wasn't just about Shalit. Not then. Not now.
He has, however, been a powerful bargaining chip for militant Palestinian groups, particularly for Hamas, now dominant in Gaza. At one point, Israel released 20 Palestinian prisoners just for a DVD showing that Shalit was still alive.
Over five years, there have been many efforts to negotiate his release — and reportedly several rescue attempts by the Israeli military, including the ground invasion of Gaza. All of them failed.
This time, though, both sides agreed to bend just enough to make a deal possible.
Israel was no longer insisting on large numbers of released prisoners being exiled to other countries (though some will go to Turkey and Jordan). Hamas was no longer insisting on certain high-profile Palestinians being set free.
In the past, Israeli Prime Minister Benjamin Netanyahu vigorously opposed this kind of prisoner swap, calling them a "lethal blow" in the war against terror and accusing his predecessors of "capitulating."
This time he rallied his cabinet to quickly approve the deal. Why would Israel do this?
Well, the Middle East is a very different place than it was five years ago when Shalit was taken hostage. And there is the potential now for even more dramatic change.
Take Egypt, for instance. Since Israel and Hamas won't talk to each other directly, Cairo has filled the key role of trusted go-between throughout Shalit's captivity.
But Egypt is no longer the reliable partner it once was for Israel. Under former President Hosni Mubarak, the Egyptian military actually helped seal Gaza, on its side, while Israeli soldiers enforced their blockade.
That border is no longer sealed. And these days, the Egyptian army isn't even able —or perhaps willing — to protect Israel's embassy in the heart of Cairo from anti-Israeli anger, a sentiment that could become official policy once a new Egyptian government is elected.
Sitting in his office in Jerusalem, Netanyahu could not have felt that time was on his side.
Besides, he's facing some pretty serious political pressure over other issues.
For most of the summer, for example, his government was under siege by Israelis denouncing inaction on basic economic problems like the high cost of housing.
Tens of thousands took their protest to the centre of Tel Aviv, pitching tents for months. One night, demonstrations across this country rallied a quarter of a million people.
How better to redeem himself, Netanyahu might have thought, than to bring home a famous son?
Shalit's jailers in Hamas have their own reasons for showing some flexibility, despite their hatred of Israel.
Over the past month, Hamas's popularity among Palestinians has been eclipsed by the dramatic moves of its political rival, Fatah, the dominant party in the other Palestinian territory, the West Bank.
Fatah's Mahmoud Abbas stole the spotlight with his speech at the UN demanding statehood for Palestinians. While that bid has not made much headway at the UN, it has certainly made headlines in the West Bank.
Abbas was feted by cheering crowds and even compared to his predecessor, the Palestinian icon, Yasser Arafat.
Hamas' objections to the statehood bid seemed meek, its role irrelevant, its leadership weak.
No longer. Now the crowds are cheering the release of hundreds of Palestinian prisoners and praising Hamas.
Fatah's UN bid? Old news.
Actually, Israel itself doesn't appear to mind bringing Abbas down a notch.
Normally, it has far better relations with Fatah than it does with Hamas — which it denounces as a terrorist organization, as does Canada and the U.S.
But Netanyahu was angered by Abbas' direct appeal for statehood (foregoing peace negotiations first) and frustrated by the inability of Israel's allies, especially the U.S., to prevent the Palestinian leader from taking centre stage in New York.
A slightly diminished Mahmoud Abbas would appear to suit Benjamin Netanyahu just fine. Especially if it also brings Gilad Shalit home.
Shalit and his family, who have become national symbols, are clear winners with this deal.
But who else wins?
Netanyahu does, certainly in the short term. Israelis have cheered. Newspaper editorials have praised him for making "courageous and correct decisions" — though there are also those who have called him "morally challenged" and "opportunistic."
Hamas has also brought itself back from the verge of political irrelevancy, which is especially important among Palestinians in Gaza who have become disillusioned by the inability of Hamas's administrative arm to create jobs and reduce poverty.
And Egypt has proven that, despite its internal turmoil, it can still play an important role in the region.
Well, aside from Abbas, possibly also Netanyahu and Israel, if those released attack Israelis once again. It has happened with previous prisoner swaps.