It is not known when Yuwen Huaji was born. He was the oldest son of the Sui Dynasty official Yuwen Shu, a close associate of Yang Guang the Prince of Jin, the son of Sui's founder Emperor Wen, and played a large role in helping Yang Guang displacing his older brother Yang Yong as Emperor Wen's crown prince in 600. Thereafter, Yuwen Huaji served as a guard commander for Yang Guang's palace. It was said that he often rode strong horses at a high speed through the streets of the capital Chang'an, holding a sling and shooting stones from the sling, and several times, he was removed from his post for receiving bribes, but each time Yang Guang persuaded Emperor Wen to restore him, and Yang Guang gave a daughter (the Princess Nanyang) to Yuwen Huaji's brother Yuwen Shiji in marriage.