The assassin droid IG-88 was able to get his hands on Darth Vader’s armor codes, and used it to take control of his movements during their fight. Darth Vader almost decapitated himself with his lightsaber, under IG-88’s control, when in the last minute he was able to use the Force to take away the remote from IG-88’s hands and regain control of himself.
From – Star Wars: Darth Vader Vol. 1 #13