Some examples from my home game. Note, "powerful" does not strictly mean "personally full of magic mojo."
Tenryu Shen: An ally who began as a mysterious foreign priest, revealed to actually be a gold dragon in disguise. He is helpful to the party and acts kind of like a friendly father or uncle figure: he's busy doing Uncle Things, but glad to help out when he can, and trusts the PCs ro help him when he needs it. His mission requires secrecy though, so he has to conceal his power, making it hard for him to just fix problems on his own. The players quite like him, much to my relief, in part because he actually does do things to make their lives easier. He's also Hafsa's fiancee.
Hafsa el-Alam: A talented Waziri mage focused on artifice and analyzing magic items. She is independently wealthy from her work, and thus invests her money into funding archaeological expeditions to uncover new things, and invests back into the community. She may not work as fast as a PC would, but she is reliable, trustworthy, and has connections fhe players don't. She ranks rather lower on the power scale, but has been a staunch ally for their entire adventuring time, so she matters a lot more than some of the others on this list despite that.
Fahd el-Sattar: Leader of the Asiad al-Khafyun, the "hidden overseers" of the Safiqi priesthood. Essentially, the chief of their internal police/spy network. Extremely powerful in a political and intrigue sense, not very powerful in terms of magic. He's effectively a divine ninja (think Avenger from 4e), mostly doing the desk job side of things in the present day. There's a mutual respect between him and the PCs, as they have aided one another, but I wouldn't call their relationship friendly per SE. Cordial, certainly not cold, but it's mostly business, not a personal connection. He's a bit too dedicated to his work for that, but that simply serves to highlight his steely resolve and borderline ruthless efficiency.
Sultana Thuriya: Monarch of the city-state of Al-Rakkah. Come to the throne at a young age, but she has proven herself in times of crisis and is beloved by her people. Composed, cool-handed and sharp-eyed, she knows she can't rule as brashly as her father did in his youth, but she can rule with cleverness and soft power just as well. The party hasn't had many opportunities to meet her (she has a full time job ruling the city, after all), but they like her and she likes them. Her power is theoretically vast, given the military and economic resources at her disposal, but limited by politics and economic realities, so the difference comes across as, "I do what I can within my fenced-in limits; I rely on you to exploit your freedom of action, to do what I cannot."
There are several others I could list, but these give a good spectrum of possibilities for "powerful NPC" that averts the risk of the NPC taking over the narrative. Each is tied down with responsibilities or connections, or cannot exercise the kinds of power and action that the player characters can. As a result, the characters are not portrayed as being "less" than these NPCs (other than maybe Shen), but rather as being different and, ideally, complementary. The NPCs can have things they want or need but cannot get, which allows rhe party to feel useful, to see how their skill sets are still useful and valuable even when they aren't "objectively" more powerful. Further, the personalities of these characters matter. Hafsa is intensely curious, but also a true philanthropist. Shen is like a father or grandfather, wise and caring, but very very devoted to his mission. Fahd is utterly no-nonsense, but his contrast of faith and pragmatism is interesting, and his forthright sincerity with the party means they know they've earned his respect, not just gotten it by proxy. The Sultana is young and sassy, but cares deeply about her role as Al-Rakkah's leader and puts the safety and well-being of the city before all other concerns.
These things, both the limitations/needs side and the actually-has-a-personality side, help prevent these NPCs from stealing the show or trivializing the PCs' efforts. The party both values them as allies and as people, and further, they know this feeling is mutual. It makes a world the players care about, one that they'll take risks to protect. It's a huge part of why I enjoy DMing as much as I do.