I remember a novella, I think it was by Jack Vance. It reminded me of the Last Castle and The Dragon Masters.
Anyway, again we have the decadent remnants of Humans. They have developed magic of a sort, curses , hexes and conjurations (which may be phantasms, but can certainly kill).
Life goes along until they are attacked by some sort of elf-like native sapient. The hexes, etc have no effect but one apprentice HexMaster develops something like science. Vinegar for example, dissolves one attack by the “elves”.