Yan Xing was from Jincheng Commandery, which is around present-day Yuzhong County, Gansu. He started his career as a military officer under the warlord Han Sui. When conflict broke out between Han Sui and another warlord Ma Teng, Yan Xing engaged Ma Teng's eldest son Ma Chao in a fight and nearly killed him by piercing him with a spear; the shaft broke so the tip only grazed Ma Chao's head. In 209, Han Sui sent him as an emissary to meet the warlord Cao Cao, who controlled the Han central government and the figureheadEmperor Xian. Cao Cao treated Yan Xing well and appointed him as the Administrator of Jianwei Commandery. Yan Xing received permission to bring his family to the imperial capital, Xu, after which he returned to Han Sui. He advised Han Sui to become a vassal under Cao Cao and send one of his sons to Xu as a "hostage", so as to express his loyalty to the central government. Although Han Sui was initially reluctant to do so, he eventually agreed and sent his family to Xu as hostages. In 211, when Ma Chao and other warlords in the Guanzhong region were planning to start a rebellion, they approached Han Sui and invited him to join them. Ma Chao even told Han Sui, "Previously, Zhong Yao ordered me to harm you. Now, I know that the people from Guandong cannot be trusted. Now, I abandon my father, and I'm willing to acknowledge you as my father. You should also abandon your son, and treat me like your son." Yan Xing advised Han Sui not to cooperate with Ma Chao but Han Sui still agreed to the alliance. Ma Chao, Han Sui and the warlords then engaged Cao Cao at the Battle of Tong Pass. During the battle, when Cao Cao requested to meet Han Sui, an old acquaintance of his, for a chat, Yan Xing accompanied Han Sui to the meeting. Cao Cao pointed at Yan Xing and told Han Sui, "Take good care of this filial son." After Cao Cao defeated the warlords at the Battle of Tong Pass, Han Sui and his remaining followers retreated to Jincheng Commandery. As Cao Cao had heard that Yan Xing was reluctant to participate in the rebellion, he spared Yan Xing's family members who were in Xu at the time but executed the families of the other rebels. He then wrote a letter to Yan Xing to inform him that even though his family members were alive and well, the central government could not permanently provide for them. When Han Sui found out that Cao Cao had spared Yan Xing's family members, he plotted to harm them so as to force Yan Xing to remain loyal to him. He then forced Yan Xing to marry his daughter. As Han Sui expected, Cao Cao became suspicious of Yan Xing. At the time, as Han Sui had ordered Yan Xing to take charge of Xiping Commandery, Yan Xing seized the opportunity to gather his followers and turn against Han Sui. However, he never managed to defeat Han Sui so he gave up and brought along his followers to join Cao Cao's side. Cao Cao enfeoffed him as a marquis. Nothing was recorded in history about Yan Xing from this point onwards.