Early in the "Kaiyuan" era (713-741) of Emperor Ruizong's son Emperor Xuanzong, Pei Yaoqing was made the magistrate of Chang'an County—one of the two counties making up the Tang capital Chang'an. At that time, Chang'an County put governmental funds in trust with rich households to have them manage the funds for the government, leading to much trouble for both government and the people. Pei ended the practice and retrieved the funds from the rich households, reducing both corruption and burden on these households. He served as magistrate of Chang'an County for two years, and it was said that he drew a balance between strictness and laxity. When he left that office, the people missed him greatly.