Emilio Morenatti, who works for the Associated Press news agency, was seized by four armed men as he was leaving his apartment on Tuesday morning.
His release came after pressure from officials from the Hamas-led government and Mahmoud Abbas, the president and head of Fatah.
Tawfiq Abu Khoussa, a spokesman for Fatah, said: "The photographer was released by the kidnappers and handed over to Palestinian security agents."
Senior security officials brought Morenatti to Abbas's office in Gaza, witnesses said.
Morenatti said: "I'm tired but happy to have come back because there were very anguished moments."
He said he was kept in a small room, where he was held for about four hours during which he was visited by masked men. He was later dressed as a woman, placed in a car and taken to another address.
Morenatti said: "They put a bag on my head and they dressed me up as a woman, as a woman in a long veil.
"I didn't know at any moment what they were doing.
"They moved me but nobody explained anything to me. It was very confusing."
"These blatant attacks on journalists will have a chilling effect on their ability to do their work and will ultimately deprive the world of information about this critically important story"
Committee to Protect Journalists
Morenatti said he was held in complete darkness for most of the time and that he could hear the sounds of a family in the second house.
The photographer thanked those who had worked for his release.
He said: "You can't imagine how much I appreciate it. I'm really very happy to come home."
Tom Curley, the president and chief executive officer of the Associated Press, said: "The Associated Press is relieved that Emilio has been released, apparently unharmed ... We appreciate the assistance offered by so many people in obtaining his release, especially Palestinian and Spanish officials."
Joel Simon, the executive director of the Committee to Protect Journalists, said: "We're dismayed that journalists have become pawns of Palestinian groups seeking to exploit them for political purposes.
"These blatant attacks on journalists will have a chilling effect on their ability to do their work and will ultimately deprive the world of information about this critically important story."
According to an official in his office, Ismail Haniya, the Palestinian prime minister, said: "The identity of the kidnappers is known and they will be prosecuted."
Luay Sakka, a Palestinian security official, said that a doorman who worked at the Gaza apartment where Morenatti was staying had been detained on suspicion of tipping off the kidnappers.
No group claimed responsibility for the abduction.
Morenatti has been working for the news agency in Jerusalem since 2005, the Associated Press said.
"You can't imagine how much I appreciate it. I'm really very happy to come home"
Earlier, Fawzi Barhoum, a Hamas spokesman, said that the abduction "does not serve the Palestinian cause".
He said: "We stress that these actions are against our culture and against our religion."
Previous kidnappings of foreigners have usually ended after a few hours, or at most a few days, of captivity.
Earlier this month, unknown armed men kidnapped an American student volunteer in the West Bank and released him hours later.
Two journalists working for the Fox news channel were abducted in the Gaza Strip in August. They were held for two weeks before being freed.