Allah states that at that tremendous moment, in which Allah differentiated between Truth and Falsehood, He sent a revelation to His servant and Messenger Musa, peace be upon him, ordering him to throw the stick that he held in his right hand,
فَإِذَا هِىَ تَلْقَفُ
(It swallowed straight away) and devoured,
مَا يَأْفِكُونَ
(all the falsehood which they showed.) the magic that they caused the illusion with, of magic with which they caused making it appear real, whereas it was not real at all. Ibn `Abbas said that Musa's stick swallowed all the ropes and sticks that the magicians threw. The magicians realized that this was from heaven and was by no means magic. They fell in prostration and proclaimed,
"So, the truth prevailed and what they were doing became a nullity. So there they were overcome and turned humiliated. And the sorcerers were constrained to fall in prostration. They said, "We believe in the Lord of the worlds, the Lord of Musa and Harun."
The sorcerers were so overawed by the miracle of the prophet Musa (علیہ السلام) that they fell in prostration. This may also imply that Allah blessed them with favour and put them in prostration. They added the phrase, the Lord of Musa and Harun (علیہما السلام) after saying, the Lord of the worlds, to make it clear that the Lord worshipped by Musa (علیہ السلام) and Harun (علیہ السلام) is, in fact, the Lord of the Universe, and not the Pharaoh as he pretended to be.
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 116–121
Prophet’s are given miracles according to the mindset of their contemporaries. In ancient Egypt magic captivated the minds of the people, so Moses was given the miracle of magic. As planned by Pharaoh, on the occasion of the national festival, all their great magicians assembled. The magicians asked Moses whether they should perform their feat first, or whether he would like to start the proceedings. Moses asked them to demonstrate their magic first, and they accepted. This shows that a prophet never takes the initiative in taking action against his enemy. Till the last moment he gives his opponents the opportunity to open hostilities. When his opponents, in this way, have already taken upon themselves the responsibility of initiating action, at that time the prophet uses all the powers at his command to subdue them. Presenting the ideology of Islam theoretically, a prophet takes the first step, but he never takes the initiative when it could lead to an offensive action.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.