Gilad Shalit, the Israeli sergeant who was held captive for five years by the Palestinian terrorist group Hamas, was released early this morning and handed over to Egyptian officals, reports said.

While there was no immediate confirmation by Israeli officals, the move appeared to be the beginning of a stunning prisoner swap in which Israel agreed to free 1,027 violent Palestinian inmates in exchange for Shalit.

A source for Hamas said Shalit, 25, was taken across the frontier from the Gaza Strip into Egypt’s Sinai peninsula, where he was handed over to Egyptians, who are expected to take him to Israel’s Vineyard of Peace border crossing a short distance away down a desert road.

Meanwhile, Palestinian prisoners were transported by bus into the West Bank, “a de facto confirmation that [Shalit], in fact, passed out of Hamas control,” the Israeli newspaper Haaretz reported.

Shalit became the first live Israeli soldier traded for Palestinians in 26 years.

According to the carefully calibrated timetable, once Israeli officials confirmed that Shalit was alive and in the hands of the Red Cross, the prisoners were to be released in groups.

In all, 477 Palestinians were to be released today, with the remainder freed in two months, beginning with 27 females.

As some of the prisoners were escorted to the buses, they were accompanied by Egyptian officials, who had mediated the deal.

The prisoners had their hands and feet shackled and there were more than 1,000 police officers lining their convey’s route, the Jerusalem Post reported.

Shalit was only 19 when he was kidnapped on the Israeli side of the Gaza Strip border in June 2006 by members of three terrorist groups, including Hamas.

He was swapped for prisoners who included some convicted in horrific suicide bombing — and whose victims included Americans.

The prisoner trade comes after years of on-again, off-again negotiations — and a painful admission by Israel’s proud military and intelligence that they couldn’t find or free Shalit.

Iranian President Mahmoud Ahmadinejad underlined the Israeli embarrassment yesterday by congratulating Hamas on its “big win.”

Overnight, thousands of Palestinians prepared to give the freed inmates a heroes’ welcome.

Israelis have traditionally been fiercely opposed to freeing inmates “with blood on their hands” — meaning they were convicted of terrorism.

But the freeing of Shalit is enormously popular. A poll released yesterday found 79 percent of Israelis were in favor and only 14 percent opposed.

Among those still opposed are relatives of victims of the jailed Palestinians, who pressed in vain for a last-minute delay yesterday.

Israeli President Shimon Peres told them, in an emotional meeting, that nothing could make up for their loss — but it was the nation’s duty to save Shalit’s life.

Prime Minister Benjamin Netanyahu, who was to greet Shalit early today, wrote an open letter yesterday to the victims’ relatives.

He noted that he lost a brother in a bid to free hostages — the 1976 Israeli commando raid on Uganda’s Entebbe airport — and he understands how the prisoner exchange reopens old wounds.

Shalit’s parents, Noam and Aviva, joined the government in pleading for the swap to proceed.

“Any delay, however small, will put Gilad’s life in danger,” they wrote Israel’s High Court of Justice, which rejected the delay.

Today’s trade could mean that a separate deal could free Ilan Grapel, a Queens-born law student with dual US-Israeli citizenship, who was jailed by Egypt in June on suspicion of spying.