One of the criminal cases against Donald Trump, widely regarded as the most perilous he has faced, has been sensationally dismissed.