He hailed from Donghai 東海 (modern Tancheng 郯城, Shandong) and succeeded his father to the post of jail overseer and guardsman (weishi 尉士). Because of his talent he was soon appointed palace aide to the Censor-in-chief (yushi zhongcheng 御史中丞). When Emperor Zhao 漢昭帝 (r. 87-74 BCE) died and the Prince of Changyi 昌邑王 was enthroned, Yu Dingguo several times remonstrated against the immoral behaviour of the new emperor. The Prince of Changyi was in fact soon deposed, and Emperor Xuan 漢宣帝 (r. 74-49 BCE), the new ruler, rewarded Yu Dingguo with the post of Grand master of splendid happiness (guanglu dafu 光祿大夫).
After a few years he was promoted to Commandant of the imperial gardens (shuiheng duwei 水衡都尉) and then Chamberlain for law enforcement (tingwei 廷尉). At that time he began studying the Confucian Classic Chunqiu 春秋 "Spring and Autumn Annals" which lead him to use capital punishment only sparingly within his jurisdiction. After 18 years in his office, he was promoted to Censor-in-chief (yushi dafu 御史大夫) and in 51 BCE succeeded Huang Ba 黃霸 in the office of Counsellor-in-chief (chengxiang 丞相). He was concurrently given the title of Marquis of Xiping 西平侯, with the posthumous title of Marquis An 安侯.