The two men were detained Monday following a joint operation by Turkey's police and its intelligence agency, according to the security official, who spoke on condition of anonymity in line with government regulations.
They appeared before court officials after four days of police questioning, which ordered them arrested on charges of "political, military and international espionage," the official Anadolu Agency reported, citing court officials.
Officials in the UAE did not immediately respond to a request for comment. Turkish state broadcaster TRT showed what appeared to be surveillance camera images of the two as well as photographs of the pair taken under police custody.
The official did not identify the suspects but said the two confessed during their interrogation that they had been spying on Arab dissidents based in Turkey on behalf of the UAE, which is Saudi Arabia's closest Arab ally.
The official said one of the two men had arrived in Istanbul shortly after the killing of Khashoggi. Security officials had been monitoring their moves for the past six months, the official said. Khashoggi wrote critically about Saudi Crown Prince Mohammed bin Salman in columns for The Washington Post before he was brutally killed and dismembered by Saudi agents, including some members from the prince's entourage.
The kingdom denies that the crown prince had any involvement. Saudi Arabia has indicted 11 suspects over the killing and is seeking the death penalty against five of them.