Dutchman Hendrik Taatgen and Brian Ambrosio, his Australian assistant, were forced from their car on Wednesday morning as they headed for work for the last day of term before Christmas holidays.
Armed men leapt from cars to snatch the principal and vice-principal of the English-speaking private American School in northern Gaza.
They were freed following the intervention of a politician from the Popular Front for the Liberation of Palestine (PFLP).
Armed members of the PFLP claimed responsibility for the kidnappings as a way of pushing for the release of jailed leaders.
The two men looked unruffled after their release, shaking hands with joyful students who had gathered to protest against the kidnapping. The men made no comment.
The PFLP has said the abduction took place to pressure the Palestinian Authority to release leaders jailed in the West Bank town of Jericho for killing an Israeli cabinet minister in 2001.
The PFLP leaders are guarded under US and British supervision.
The abductions are the latest in a string of kidnappings in the Gaza Strip where armed men, acting in the name of resistance against Israel, frequently operate beyond the law.
It is the first time that the PFLP has been involved.
Hader Abdul Shafi, the head of the Palestinian Red Crescent Society, said: "This is unacceptable aggression, they are criminals."
Similar kidnappings have often been resolved within hours and the captives released unharmed, but they are an embarrassment for Mahmoud Abbas, the Palestinian president.
Lawlessness in Gaza has been an
embarrassment for Abbas
The PFLP has Marxist roots and opposes peace talks with Israel. The group, which was at the forefront of air hijackings in the 1960s and 1970s, is part of Abbas's umbrella Palestine Liberation Organisation.
PFLP leaders detained in Jericho include Ahmed Saadat and others behind the assassination of an ultranationalist Israeli cabinet minister.
The PFLP had said that killing was to avenge the death of one of its own leaders.
Chaos has intensified in the Gaza Strip since Israel completed its withdrawal of troops and settlers from the territory in September after 38 years of occupation.
Abbas's failure to bring order is widely seen as a factor that could help to boost the conservative Islamic movement, Hamas, ahead in parliamentary elections set for 25 January.