Yes, the Spanish word que and the Persian word ke are cognates, both descending from the Proto-Indo-European (PIE) interrogative and relative stem *kʷ-.
Spanish que (and qué)
Proto-Indo-European (PIE): The forms kʷís ("who?") and kʷíd ("what?") are the ultimate root. The stem kʷ- represented both interrogative ("who?", "what?") and relative ("that," "which") pronouns in PIE.
Latin: From PIE, these developed into the Latin pronouns quis and quid. Over time, these Latin forms evolved and merged to become the Old Spanish que.
Old Spanish: Old Spanish que inherited the functions of both the interrogative and the relative pronoun from Latin.
Modern Spanish: Today, the word maintains both functions. The accent mark distinguishes them in writing:
Qué (with an accent) is the interrogative pronoun, meaning "what?" or "which?".
Que (without an accent) is the relative pronoun or a conjunction, meaning "that," "which," or "who".