Wei Xuantong himself had passed the imperial examination, and thereafter became the magistrate of Chang'an County, one of the two counties making up Tang's capital Chang'an. By 664, he was serving as the director of performance reviews at the ministry of civil service, when, on account of his friendship with the chancellor Shangguan Yi, who had been executed after unsuccessfully trying to persuade Emperor Gaozong to depose his powerful wife Empress Wu (later known as Wu Zetian), Wei was exiled to the Lingnan region. It was said that during his exile, he was not particularly interested in returning to politics, and he spent most of his days hunting.
Early in Emperor Gaozong's Shangyuan era (674–676), there was a general pardon, and Wei was recalled to the capital. Liu Shenli (劉審禮) the minister of public works was aware of Wei's talent, and he recommended Wei. Wei was subsequently made the secretary general of Qi Prefecture (岐州, roughly modern Baoji, Shaanxi), and then the deputy minister of civil service. In 682, he was given the designation Tong Zhongshu Menxia Pingzhangshi (同中書門下平章事), making him a chancellor de facto. He was also created the Baron of Julu.
Around this time, Wei also submitted a lengthy petition to Emperor Gaozong, advocating a major reform of the civil service system. In his petition, he pointed out that during the Zhou dynasty and Han dynasty, the responsibilities for recommending, promoting, and evaluating officials were split between various central government officials and local officials, and that only during Cao Wei and Jin dynasty (266–420) did the responsibilities began to be concentrated in a single ministry of civil service—a system that he found faulty in that it required a small number of officials to make snap judgment as to the merits of the officials for the entire state, and therefore, even if the officials were capable and honest, they would not be able to make correct decisions all the time—and that the system was open to manipulation through corruption or incompetence. Emperor Gaozong did not take action on his petition.
It was also around this time that Wei would bring an enmity against him that would eventually be his undoing. At this time, Zhou Xing, the magistrate of Heyang County (河陽, in modern Jiaozuo, Henan), had become known for his abilities, and was summoned to the capital, as Emperor Gaozong was considering promoting him. However, someone submitted a letter to Emperor Gaozong, pointing out that Zhou had not passed imperial examinations, and Emperor Gaozong changed his idea about promoting Zhou. However, Zhou was not aware of this, and he repeatedly visited the government officials, awaiting a promotion. The chancellors said nothing to him, but eventually Wei told him, "Magistrate Zhou, you may go." Zhou thereafter believed that Wei was the one who blocked his promotion, and hated Wei immensely.