For Foreign Minister Murray McCully, yesterday was surely the worst of days transformed into the best of days.
In the morning, he told a press conference he had apologised to the Prime Minister after his Ministry of Foreign Affairs had made a complete and utter botch of its handling of the case of the Malaysian diplomat who had invoked diplomatic immunity and fled the country after facing sexual assault charges.
Both McCully and John Key had stood firm on the principle that the diplomat - a defence staff assistant in the Malaysian High Commission in Wellington - should not benefit from such immunity given the crime he was alleged to have committed.
New Zealand still wanted Malaysia to waive that immunity. If that did not happen, extradition was an option.
The rug was pulled from under them, however, by the ambiguity of some of the ministry's "informal communications" with the high commission.
These contacts had left open the possibility of a different course of action and ended up delivering exactly the opposite outcome than the Government had wanted - that New Zealand was happy for the disgraced diplomat to return home.
This appalling piece of diplomacy was effectively trumped last night with common sense prevailing and Malaysia announcing the diplomat would return to New Zealand "to assist in the investigation of the charges".
The decision would have been no skin off Malaysia's nose, but enabled McCully - who had spent the day apologising to all and sundry - to grasp a reasonable victory from the jaws of defeat.
The question remains as to why the officials got it it so wrong initially. And, having got it so wrong, why they compounded the problem by failing to tell their superiors while supplying incomplete briefing material to Key and McCully.
The question might get an answer after an independent review initiated by John Allen, the ministry's chief executive, has focused on those "informal communications".
The debacle brought the chain of responsibility into sharp focus. It is unlikely McCully offered Key his resignation. McCully can claim the old defence of being responsible, but not to blame. And, anyway, Key would never have accepted his resignation - especially in the light of last night's stunning breakthrough.
Allen is understood to have offered to step down, but was apparently told likewise by McCully to stay on.
So the lower-level officials are the ones in the gun. They have some rather tricky, but crucial questions to answer.