The magicians were the first to understand. The Quran says that they fell down in prostration (7:120; 26:46) and said, in the meaning of the verses, that they believed in the Lord of the worlds, the Lord of Musa and Harun (Aaron) (7:121-122; 20:70; 26:47-48). They knew the limits of their art, so they recognized that this was not magic.
Pharaoh answered with anger. He said that they had believed before he gave permission, that this was a plot, and he threatened to cut off their hands and feet on opposite sides and to crucify them (7:123-124; 20:71; 26:49).
The magicians replied with a famous answer. In the meaning of Quran 20:72-73, they said: we will never prefer you over the clear proofs that came to us and over Him who created us, so decree whatever you decree, for you can only decree in this worldly life. We have believed in our Lord so that He may forgive our sins and what you forced us to do of magic.
Surah al-A'raf records their dua: وَمَا تَنقِمُ مِنَّآ إِلَّآ أَنْ ءَامَنَّا بِـَٔايَٰتِ رَبِّنَا لَمَّا جَآءَتْنَا ۚ رَبَّنَآ أَفْرِغْ عَلَيْنَا صَبْرًۭا وَتَوَفَّنَا مُسْلِمِينَ The meaning is that Allah would pour patience upon them and let them die in submission to Him.