Little is known about Yu Ningji's family background, other than that he was a younger second-cousin of the more well-known Former Shu official Yu Chuansu, who served as a chancellor during the reigns of both of Former Shu's emperors, Wang Jian and Wang Zongyan.
During Wang Jian's reign
At one point during Wang Jian's reign, Yu Ningji became an imperial scholar. By 917, he was serving as the chief imperial scholar. In the fall that year, the powerful eunuch Tang Wenyi accused then-director of palace communications Mao Wenxi of overreaching, Wang Jian exiled Mao and replaced him with Yu on an acting basis. Later in the year, Wang Jian officially made Yu director of palace communications, and also made him the minister of civil service affairs. When Wang Jian became deathly ill in summer 918, Wang Jian, after exiling Tang after accusations by his adoptive son Wang Zongbi, whom he was intending to entrust his son and crown princeWang Yan to, that Tang was intending to seize power, put Yu in charge of matters of finance, civil service, and justice, while putting the eunuch Song Guangsi in charge of military dispatches. Shortly before his death, he further made Song director of palace communications — while the historical records were silent as to whether, simultaneously, Yu remained as director of palace communications as well, or whether Yu was relieved of that post and only serving as minister of civil service affairs. After Wang Jian's subsequent death, Wang Yan took the throne as emperor. Wang Jian's last edict, naming the officials whom he entrusted the new, young emperor to, did not name Yu among the officials. , Wang Zongwan, and Wang Zongkui
During Wang Yan's reign
However, whether Yu Ningji remained as director of palace communications or not, he remained in charge of matters of justice, for it was apparently he who oversaw the subsequent demotion and punishment of the chancellor Zhang Ge, a major political ally of Tang Wenyi's, after Tang was executed shortly after Wang Yan took the throne. It was Yu who proposed to exile Zhang to Heshui Base. He further ordered Gu Chengyan, the prefect of Mao Prefecture, which Heshui belonged to, to spy on Zhang, hoping further chances to accuse Zhang. After Gu declined to do so, Yu found an excuse to punish Gu. That was the last historical reference to Yu, and it was not known when he died.