This question already has an answer here:
I'm looking for a fantasy novel that has the back story of having two great elemental magic users (not sure what they are called in the novel). One can use fire and earth, the other water and air. They join forces to defeat demons. The novel starts long after that has ended, and only one remains. The demons are posing a threat again so the master seeks an apprentice, fusing him with a gem to grant him power.
The gem tries to gain control of the boy, but the boy emerges with the power instead. It is then learned that the gems are actually technology from a long-lost race, and the demons are actually aliens.