At that moment, Prophet Moses (PBUH) knew that Allah (swt) would grant him victory, and he had been previously trained by Allah (swt) to throw his staff. Nonetheless, Allah (swt) says: (And We inspired); this Divine inspiration was sent to keep him firm and resolute in the face of this vast crowd and the formidable sorcery.
Allah (swt) inspired Prophet Moses (PBUH) to throw his staff. As a result, Prophet Moses (PBUH) cast his staff, and it instantly transformed into a large serpent, thereby nullifying the effects of their sorcery. The staff devoured all the ropes and sticks that had been brought by the magicians.