snatch defeat from the jaws of victory
To suddenly lose a contest one seemed very likely to win, especially through mistakes or bad judgment.
1874, Illinois sports pages, "but when they [the Whitesocks baseball team] snatch defeat from the jaws of victory there can be little sympathy for their deserved misfortune." (Quot