GAZA — Egypt reopened its borders with the Gaza Strip on Saturday five days after closing the crossing, which had prevented people from entering or leaving the Palestinian enclave and deepened its isolation from the rest of the world.

Egypt opened the Rafah crossing for four hours, allowing about 345 Palestinians to leave Gaza and 619 people to enter, many of whom had been stuck for days on the Egyptian side, said Maher Abu Sabha, director of crossings in the Hamas government.

Egypt’s military-led government had essentially sealed off the territory, shutting down not only the travel crossing but also hundreds of smuggling tunnels that Gaza relies on for building materials, cheaper fuel, weapons and other products restricted by Israel. Most of the tunnels remained closed.

Traffic through Rafah has been cut by 75 percent since the July 3 ouster of Egypt’s Islamist president, Mohamed Morsi, according to Gisha, an Israeli group that tracks the crossing as part of its advocacy for access to Gaza. Rafah is the main crossing point and gateway to the world for most Gaza residents, as Israel generally restricts travel through its Erez crossing at the northern border to medical patients, merchants and foreigners.