It lost by a minuscule margin. Of those two disasters, the latter is the bigger one. A big defeat can carry within it a great blessing.
Military history abounds in such examples.
Ehud Barak, who enjoys studying the history of wars, could undoubtedly quote a number of such examples. For instance, Prussia crumbled in humiliating fashion in the face of Napoleon's army in 1806. Prussia took stock and carried out sweeping reforms in the military and the state. As a result, it transformed itself into a world power. In the Israeli elections for Prime Minister, Netanyahu defeated Peres by a margin of 29,457 votes.