By Laura Trevelyan
BBC UN correspondent
Entire neighbourhoods have been flattened in Gaza
After seven hectic days in the Middle East, the UN chief is heading back to New York.
Ban Ki-moon's aim when he left was to press for a ceasefire in Gaza, and call for humanitarian aid to be delivered to those in need. He returns with two ceasefires, and no Egyptian-negotiated truce agreement between Israel and Hamas.
Mr Ban sped around the Middle East with remarkable speed and determination. Those of us following him climbing in and put of helicopters were struck by his energy and focus. Mr Ban counted 14 cities he had visited in a week, meeting the region's leaders.
Yet how much impact did he have on Israel's decision to announce a ceasefire, swiftly followed by Hamas?
Mr Ban certainly supported the Egyptian efforts to broker a truce, applied public pressure for a ceasefire by the fact of his visit, and discussed options for an agreement with everyone - from President Hosni Mubarak of Egypt to Palestinian leader Mahmoud Abbas.
Mr Ban did not meet with representatives from Hamas, as he deals with what he calls the internationally recognised Palestinian Authority. The UN does have contact with Hamas through its work in Gaza though.
In the end, Israel stuck to its own timetable of wrapping up the military offensive in Gaza - in time for the inauguration of US President Barack Obama.
However, Mr Ban did publicly call for Israel to call a unilateral ceasefire, when it became clear to him that the Egyptian peace talks weren't reaching agreement on how to stop Hamas smuggling weapons into Gaza and how to re-open the border crossings into the strip to allow food and aid to get in.
And Israel did call a unilateral ceasefire, so at the very least that was an astute reading of Israel's options by the softly spoken secretary general.
Mr Ban also had to grapple with the complex and often fraught relationship between Israel and the United Nations.
Mr Ban vowed to work for a lasting solution to the conflict
The role of the UN's relief and works agency in providing food, schools and medical care to Palestinian refugees, as it has done since the creation of Israel in 1948, is a flashpoint for the Israeli government.
Unrwa - as it is known - is a powerful force in the Gaza Strip, employing 10,000 people.
Many Israeli officials regard Unrwa with suspicion, and one spokesman even claimed that many Unrwa local staff were one way or the other affiliated with Hamas.
UN schools were damaged; on one occasion 43 people sheltering at a UN school were killed by what the Israelis said was a stray motar.
Standing in front of the damaged UN warehouse in Gaza City, where the flour due to be delivered to the Palestinians was still burning following an Israeli attack last Thursday, Mr Ban pronounced himself appalled by the scenes of wreckage.
"I am not able to describe how I am feeling," he said sadly, as unexploded rockets lay wedged into the ground close by, and the twisted metal warehouse doors smouldered.
The secretary general met Israel's leaders last Thursday on the day of this incident, and - after protesting angrily - he received apologies and assurances that UN buildings and staff would be respected.
Two days later, another UN school was hit and two young brothers died, their anguished mother lost her legs. Mr Ban was furious, yet there was nothing he could do.
Hopes on Obama
John Ging of Unrwa has raised the question of whether Israel's government should be investigated for committing possible war crimes against Palestinians.
In reality, a war crimes investigation by the International Criminal Court is unlikely
"For all those innocent people who have been killed in this conflict, were they war crimes? International law obliges is to get an answer to that question," he said.
Mr Ban has been more cautious, saying it is not for him to determine whether a war crimes investigation should take place. However, he has stressed the importance of accountability, where necessary.
In reality, a war crimes investigation by the International Criminal Court (ICC) is unlikely. The court's prosecutor and pre-trial chamber can only instigate their own proceedings against a state that belongs to the court. Israel is not a formal member.
The UN Security Council has been known to refer cases against non-members to the ICC, but the US, staunch ally of Israel, could well block such a move. A state party to the court can ask for a referral to the ICC, but there is no Palestinian state.
Mr Ban flies back to New York pledging to work for a lasting solution to the Israeli-Palestinian conflict.
His hope is that President Obama will press for a two-state solution at the very start of his presidency, providing a new dynamic which might help resolve this age old problem.
Update: In February 2009, the United Nations said that a clerical error had led it to report that Israeli mortars had struck a UN-run school in Jabaliya, Gaza, on 6 January killing about 40 people. Maxwell Gaylord, the UN humanitarian co-ordinator in Jerusalem, said that the Israeli Defense Force mortars fell in the street near the compound, and not on the compound itself. He said that the UN "would like to clarify that the shelling and all of the fatalities took place outside and not inside the school".