Imagine a typical fantasy world, where wizards need to perform rituals, or specific hand movements, and utter specific phrases with correct pronunciation to trigger well-defined magic spells. The reader later finds out that long ago, there was a highly advanced technological civilization which created magic by building advanced AIs and a network of nanomachines, which actually listen to specific keywords and hand movements then implement the spells themselves. They then either collapsed or went into hiding.
Where does this idea originate from, which was the earliest work of sci-fi built around this idea? There are some examples, like some Harry Potter fan fiction, or the Ra series, but they are relatively recent.
Just having very advanced technology, which is misinterpreted by less advanced people as magic does not count. Most (or all) magic practitioners have to "study" magic by experimenting with different hand motions and pronunciations, without knowing anything about the underlying causes.