He was the eldest son of Count William III of Weimar from his second marriage with Oda, a daughter of Margrave Thietmar of the Saxon Eastern March.
William remained a loyal supporter of the ruling Salian dynasty and, upon the death of the emperor in 1056, backed the regency of his widow Empress Agnes of Poitou.
He was highly in favour with the empress, who gave him command alongside Bishop Eberhard of Naumburg, of the army in the 1060 campaign in support of King Andrew I of Hungary against his brother Béla I.
According to the chronicler Lambert of Hersfeld, instead of waiting for an assisting Bohemian contingent under Duke Spytihněv II, they immediately attacked Béla's forces and the German army was soon in retreat.
However, Béla's son Géza, impressed by William's courage, induced his father to not only release him, but give him his daughter Sophia in marriage.