Palestinian children from the Gaza Strip pose in the Al-Aqsa mosque compound in Jerusalem's Old City on Sunday as they visit the city for the first time as part of an exchange program run by the U.N. agency for Palestinian refugees. (Ahmad Gharabli/AFP/Getty Images)

It was a journey of just 50 miles, but for the nearly 100 children who visited Jerusalem on Sunday, it seemed like they had traveled to a distant world. 

For the vast majority, it was their first trip outside of Gaza, the largely blockaded enclave they call home. Selfie sticks abounded as they visited the al-Aqsa Mosque compound, the third-holiest site in Islam, to pray.

Many said it was also the first time they had seen an Israeli.

Razan Farrah, 12, enthusiastically recorded video of the winding streets of the Old City, holding her cellphone up to the face of a ­bemused-looking Western tourist and then a passing ultra-Orthodox Jew. 

Her eyes widened. “I haven’t seen them before,” she explained, never lowering her phone. She zoomed in on the trinkets on sale in front of the tourist-trap stores. “I want to keep the memories.” 

A Palestinian boy from the Gaza Strip takes a photo inside the Dome of the Rock mosque in the Al-Aqsa mosque compound in Jerusalem's old city on Sunday as he visits the city for the first time. (Ahmad Gharabli/AFP/Getty Images)

A small number of Gaza’s residents are granted permission to leave the densely populated 140-square-mile strip of land that stretches along the Mediterranean, with both Israel and Egypt imposing restrictions on travel and trade. Israel says it issued 80,000 permits in 2016, for a population of 2 million. They go to the urgently sick and others with exceptional needs for travel.

But this year the number of permits granted has drastically dropped, according to Gisha, an Israeli organization that tracks Palestinian freedom of movement issues, with about half as many issued in July compared with the same month last year. Meanwhile, the Palestinian Authority has attempted to squeeze Hamas, the Islamist militant movement that rules the strip, by cutting the electricity supply , compounding misery for residents there. 

“We thank God we are still living,” chirped Samah Lubad, an 11-year-old dressed in a white shirt with a Goofy cartoon print. “You learn to adapt to your surroundings.” 

The trip took six months to organize, according to Scott Anderson, the West Bank field director for the U.N. Relief and Works Agency. Just seven of the 91 children had been outside Gaza before, he said. 

The children will travel on to the West Bank, where they will stay until Friday, visiting Palestinian cities including Ramallah and Nablus. Some 38 children from the West Bank visited Gaza as part of the exchange. 

With Gaza physically cut off from the West Bank, it will also be the first time most of the children have seen the rest of the Palestinian territories — and for some, relatives who live there. 

Israel says it was forced to impose a partial trade and travel blockade on Gaza because of the security threat posed by Hamas, which seized control in 2007 after an armed struggle that followed their electoral win. Israel and the United States consider Hamas a terrorist organization.

Israeli authorities say Gaza residents could smuggle out contraband for Hamas to use in attacks. Human rights groups argue that the restrictions violate the fundamental right of Palestinians to freedom of movement. 

The only other land border, to Egypt, has also largely been closed for the past four years, though it opened for exiting residents for the first time in months last week. 

The children all attended ­UNWRA’s summer camp program, and were interviewed and picked based on their leadership skills. 

“I hadn’t expected there to be so many entrances,” Lubad said of the Dome of the Rock, the site where Muslims believe Mohammed ascended into heaven. “We have a picture of it at home, but in reality it’s so huge.” 

Her friend said it was smaller than she had expected — but still beautiful. They hurried in as prayers began. 

Her family asked her to take photos and to pray at what Muslims call the Haram al-Sharif, or the Noble Sanctuary, the raised esplanade where it is located, alongside the gold-domed Dome of the Rock. Jews call the area Temple Mount, the site of their first and second temples, and the most holy site in Judaism.

Lubad said she had barely slept the previous evening, because she was so excited but also afraid that Israeli soldiers would stop her from crossing. 

In the end, the crossing went relatively smoothly, with the children turning up only an hour and a half late for their lunch in the Old City.

Her friend, Lana Meater, though, said she had been afraid though as her impression was that Israeli soldiers were “savages.”

Israel withdrew from Gaza in 2005, but Israel and Hamas have fought three wars in the last 10 years, the most recent in 2014, during which more than 1,400 Palestinians were killed according to the U.N. Israel says it was forced to launch the assault due to Hamas rocket fire. 

Before leaving for Ramallah, the children also visited the Church of the Holy Sepulchre, Christianity’s holiest shrine and the highlight of the trip for the one Christian Gazan. 

“I’m so happy,” Hamada Atta al-Masri, 14, said. “The sightseeing, the streets, al-Aqsa. Maybe we’ll see it again, maybe we won’t. But at least we’ve seen it.” 

Sufian Taha contributed to this report.