According to the World History Encyclopedia there are ancient Egyptian writings named the Westcar Papyrus and regarding magic and miracles dating as far back as approximately 2040 BC.
Stories from the Westcar Papyrus, World history encyclopedia
The Westcar Papyrus, dated to the Second Intermediate Period of Egypt (1782 - c.1570 BCE), but most likely written during the Middle Kingdom (2040-1782 BCE), contains some of the most interesting tales from ancient Egypt. The papyrus takes its name from the man who first acquired it, Henry Westcar, who purchased the piece c. 1824 CE. Westcar never disclosed how he came into possession of the scroll nor where, and so no one knows in what context it was found or its original location.
These stories, which include a Wax crocodile which is brought to life by a magician to devour people, are believed to have simply been made up stories, though as the world history encyclopedia explains, this is just an opinion and speculation. "Perhaps they were meant to be taken literally".
World history Encyclopedia
There were originally five stories in the manuscript but the first is missing (and, according to some scholars, so is the conclusion of the papyrus). It is assumed that the work began with some kind of invitation by Khufu to his sons to tell stories about great wonders of the past or perhaps it was a competition among the sons to tell the best kind of story. This is, of course, speculation as no internal evidence in the texts suggests its beginning.
Westcar Papyrus by Keith Schengili-Roberts, Wikipedia
There is no doubt however that the Egyptians did believe in Magic to a certain degree.
According to the world history encyclopedia there was such a thing as the execration texts that were used to curse evil spirits and enemies of the Egyptian state.
World history encyclopedia, execration texts
'Execration' means to denounce or curse a person, entity, or object one finds detestable, dangerous, or offensive in some way. These texts were not only curses but specific formulae designed to ward off or destroy harmful entities before they had a chance to harm someone or, in the case of physical or mental illness, to drive the evil spirit out and banish it from returning.
Execration texts, therefore, are the earliest known form of exorcism and were used regularly. Over one thousand of these ritual texts have been excavated thus far in Egypt. The best-known execration texts in the modern day are the famous curses inscribed on tombs warning of punishment for any who entered the tomb unwelcomed or unpurified. The famous 'Curse of Tutankhamun' also known as 'the mummy's curse', well known from Hollywood movies, is the best example of an execration text.