Yankees nearly snatched defeat from the jaws of victory