Egypt released an American-Israeli held as an alleged spy and Israel freed 25 Egyptians in a prisoner swap Thursday that will ease strains between Cairo's new rulers and the United States and Israel.

Ilan Grapel, 27, flew to Israel accompanied by two Israeli envoys sent by Prime Minister Benjamin Netanyahu. The freed Egyptians crossed overland into Egypt's Sinai desert, some of them kneeling in a thanksgiving prayer.

A smiling Grapel hugged his mother, Irene, on the tarmac at Tel Aviv's Ben Gurion Airport after climbing out of a private jet and Netanyahu later greeted him at his Jerusalem office and exchanged a firm handshake, but few words for the cameras.

At a news conference afterwards, Grapel said he was well treated during his detention. Standing alongside Congressman Gary Ackerman (D-New York) who had pushed for his release, Grapel also thanked the Israeli and U.S. officials involved.

Despite the circumstances and turmoil going on in Egypt ... the Egyptian authorities treated me respectfully, according to the tenets of their religion, made sure that I was fed well ... and made sure that no one harmed (me) in any way, he said.

There are so many to thank after being cut off for the last five months and I'm learning about all the people working on my behalf, he added, mentioning Netanyahu, U.S. Secretary of State Hillary Clinton, Defence Secretary Leon Panetta and his predecessor, Robert Gates, among others.

Egypt arrested Grapel in June on suspicion that he was trying to recruit agents and monitor events in the revolt that toppled Hosni Mubarak, an ally of Israel and the United States.

Israel denied that Grapel, who emigrated from New York in 2005 and was wounded as an Israeli paratrooper in the 2006 Lebanon war, was a spy.

His links to Israel were apparent on his Facebook page, which contained photos of him in Israeli military uniform.

A law student in the United States, Grapel was working for Saint Andrew's Refugee Services, a non-governmental agency, when he was detained.

Grapel said in Hebrew at the news conference that he had been arrested under false allegations.

The United States, which provides the army that now runs Egypt with billions of dollars in military aid, had called for Grapel's release. He was freed three weeks after Panetta visited Egypt.

A State Department spokeswoman in Washington said the United States welcomed Grapel's release and thanked Egypt and Israel for their efforts to secure the deal and their role in reuniting him with his family.

Spokesperson Victoria Nuland added: The Egyptian-Israeli Peace Treaty is a vital element of regional peace and stability, and we strongly support both countries' sustained commitment to its provisions.

The U.S.-brokered exchange was reached shortly after a more high-profile, Egyptian-mediated swap between Israel and Gaza's Hamas rulers freed captive Israeli soldier Gilad Shalit in exchange for more than 1,000 Palestinian prisoners.

Eli Avidar, a former diplomat who headed Israel's mission in Qatar, said securing the release of Egyptian prisoners could help Cairo's new leaders domestically.

The Egyptian administration needs this for its prestige, he said on Israel's Channel 1 television.

Israel is widely unpopular in Egypt, which signed a peace treaty with its northern neighbour in 1979.

EMBASSY ATTACK

In September, Israel flew its ambassador out of Egypt when the Israeli embassy was attacked by protesters angry at the killings of Egyptian border guards when Israeli troops pursued raiders who killed eight Israelis in August. Israel said the gunmen infiltrated from the Gaza Strip via the Sinai.

Many of the Egyptian prisoners on the release roster were jailed for drug trafficking, infiltration into Israel and gun-running, but not for espionage or attacks on Israelis, Israel's Prison Service said.

Raise up your heads, you are Egyptian, relatives of the freed Egyptians cried, waving the country's red, white and black flag as the bus carrying the men crossed the border.

I've been in jail since 2005. Thank God. I feel reborn, Mursi Barakat told Egyptian state television. The treatment in jail was very tough and it was clear there was discrimination.

Ackerman travelled to Israel to accompany Grapel back to the United States, his office said in a statement. The congressman said Grapel had once worked for him as an intern.

Israel has also called for steps to help free another Israeli, Oudeh Suleiman Tarabin, jailed by Egypt.

Egypt's South Sinai governor Khaled Fouda told reporters after the handover: This is the biggest prisoner swap deal since 1948 ... There will be more deals in the future.

Amos Gilad, a senior Israeli Defence Ministry official, rejected arguments by right-wingers in Israel that it had capitulated to Egypt in the 25-1 exchange.

The bottom line is you have to decide, will he (Grapel) stay there in prison, or not? If you ask me, he needed to be freed, Gilad said on Israel Radio.

(Additional reporting by Dan Williams and Ori Lewis in Jerusalem and Shaimaa Fayed and Omar Fahmy in Cairo; Writing by Jeffrey Heller and Edmund Blair; Editing by Tim Pearce)