Make the NPC's power a tool to create adventures and situations you usually couldn't do. Done right, the NPC might not replace the PC's, but rather, he's a powerfull weapon.
examples:
Scyscribes/Fajitas storyhour recently had a well done passage where the PC's fight alongside a far more powerfull NPC archmage and where still instrumental.
Last session I played in, we had to destroy a lich and where accompanied by a uber NPC. The uber NPC went and defeated the lich, but was teleported away in the process of stage. We then had to figure out that the lich has a philactery, find it and destroy it before the lich regenerated (this was an especially fast rejuvenating species). The uber NPC beat the baddy, but the actual defeat came through the PC's.
The old Against the Cult of the reptile God module has a more powerful wizard accompanying the PC's. But instead of defeating the BBEG singlehandetly, he neutralises his powerfull magic, so the PC's can take him down.
The manga naruto has the young main characters travel along with their far more powerfull mentor, but still manages to showcase the young characters:
In the first combat, the mentor fights an equal opponent and at one point becomes trapped. The young pupils are adviced to run away, but instead figure out how to free they mentor, leading to the opponents defeat.
In another fight, the mentor confronts the equal opponent, while the main characters fight the opponents own equally young, but brilliant pupil.
Also, not every NPC needs to be as combat centered as PC's tend to be. Remember, PC's are build and prepare spells to pretty much always be ready for an all out combat and focus way more on offensive than most people really would. A real high level wizard will keep more defensive and utility spells prepared than right out combat spells, even when going on a trip through dangerous terrain.
You can have combats where the mentor holds off the opposition, while the PC's need to fullfill some task, fights where the NPC is out of spells, fights where the NPC's abilities are negated, fights where the NPC needs all his power to negate one opponent/one opponents powers, fights where the NPC bears the brunt, but the PC's need to make one crittical intervention and fights where the PC's are simply wawy from the mentor on some errant.