Why James Comey fired for mishandling Clinton emails or investigating Trump and Russia?

This afternoon, White House spokesman Sean Spicer said, “The president has accepted the recommendation of the Attorney General and the deputy Attorney General regarding the dismissal of the director of the Federal Bureau of Investigation.” The bureau’s director was fired. Was he fired for mishandling the Clinton emails, or because he was investigating the Trump campaign’s Russia ties?