Red Cross vehicles drove away from the handover site in the Gaza Strip with four black coffins that had been placed on a stage. Each of the caskets had a small picture of the hostages.
Armed Hamas militants in black and camouflage uniforms surrounded the area.
United Nations rights chief Volker Turk called the parading of bodies in Gaza abhorrent and cruel and said it flew in the face of international law.
"Under international law, any handover of the remains of deceased must comply with the prohibition of cruel, inhuman or degrading treatment, ensuring respect for the dignity of the deceased and their families," he said in a statement.
After the hostages were handed over by the Red Cross, the coffins were scanned for explosives, according to the military, before being transported to Israel.
Israelis lined the road in the rain near the Gaza border to pay their respects as the convoy carrying the coffins drove by.
"We stand here together, with a broken heart, the sky is also crying with us and we pray to see better days," said one woman, who gave her name only as Efrat.
In Tel Aviv, people gathered, some weeping, at what has come to be known as Hostages Square outside Israel's defence headquarters.
"Agony. Pain. There are no words. Our hearts — the hearts of an entire nation — lie in tatters," said President Isaac Herzog.
Prime Minister Benjamin Netanyahu said the country was "united in unbearable grief" and vowed to "eliminate" Hamas.
In Gaza, as the bodies were handed over, militants stood beside a poster of a man standing over coffins wrapped in Israeli flags. Instead of legs he had tree roots in the ground, suggesting the land belongs to Palestinians. The poster read "The Return of the War=The Return of your Prisoners in Coffins".
The two boys, their mother Shiri Bibas and a fourth hostage, Oded Lifschitz, were handed over under the Gaza ceasefire agreement reached last month with the backing of the United States and the mediation of Qatar and Egypt.
Kfir Bibas was nine months old when the Bibas family, including their father Yarden, was abducted at Kibbutz Nir Oz, one of a string of communities near Gaza that were overrun by Hamas-led attackers from Gaza.
Hamas said in November 2023 that the boys and their mother had been killed in an Israeli air strike but their deaths were never confirmed by Israeli authorities.
"Shiri and the kids became a symbol," said Yiftach Cohen, of the Nir Oz kibbutz, which lost around a quarter of its residents, either killed or kidnapped, during the assault.
Yarden Bibas was returned in an exchange for prisoners this month.
Some of those Israelis killed on October 7 were known peace activists.
Lifshitz was 83 when he was abducted from Nir Oz, the kibbutz he helped found. His wife, Yocheved, 85 at the time, was seized with him and released two weeks later, along with another woman.
"Our family's healing process will begin now and will not end until the last hostage is returned," the family said.
The Hamas-led attack into Israel killed some 1200 people, according to Israeli tallies, with 251 kidnapped. Israel's subsequent military campaign has killed some 48,000 people, Palestinian health authorities say, and left densely populated Gaza in ruins.
The handover marks the first return of dead bodies during the current agreement.
Thursday's handover of bodies will be followed by the return of six living hostages on Saturday, in exchange for hundreds more Palestinians, expected to be women and minors detained by Israeli forces in Gaza during the war.
Negotiations for a second phase, expected to cover the return of around 60 remaining hostages, less than half of whom are believed to be alive, and a full withdrawal of Israeli troops from the Gaza Strip to allow an end to the war, are expected to begin in the coming days.