When a West African nation teetered on the edge of chaos, two unlikely figures moved behind the scenes to shape its future.