While I think it is a stretch to call them "advanced" aliens, I'm going to agree with @Boelabaal and say that this idea first appeared in the works of H.P. Lovecraft.
In fact, there's an entire book that backs up this claim: The Cult of Alien Gods, by Jason Colavito, argues that the concept of "ancient aliens" being mistaken for gods, as described in the classic work of pseudo-scientific garbage Chariots of the Gods?, draws directly from the Cthulhu Mythos.
Lovecraft started writing in 1919, and many of his stories involve the (re-)discovery of ancient gods. For example, "The Other Gods", in 1921, is a story about a priest who tries to find the ancient gods of his people, only to find out that his gods have gods of their own:
other gods, the gods of the outer hells that guard the feeble gods of earth!
Though these aliens are clearly not from Earth, they're never explicitly called aliens (they're described more in terms of other dimensions than other planets.) As far as I remember, the first time this happens is in "The Call of Cthulhu". Again, the story strongly implies, but never actually claims, that Cthulhu is an alien, but Lovecraft would make that connection directly in some of his letters, and in later Cthulhu Mythos stories.