Granted, Mystra is only in the Realms, but there are dieties of magic in the other settings, so wouldn't they be the source of magical energy in their 'realm'? And if so, then if they die, doesn't magic die? Thus, magic exists because of a diety. Your still just another type of cleric! And if this doesn't apply to your setting, at least it sure seems the way in the FR, so Elminster is a frickin' cleric!
Oh, and the Spell Book wasn't so much your actual god, just your 'divine focus' to your god.