Rudolf II was born in Rheinfelden, Swabia, the youngest son of Count Rudolf of Habsburg and his first wife Gertrude of Hohenberg to survive infancy. In 1273 his father was elected king of Germany, the first of the Habsburg dynasty, whereafter he seized the "princeless" duchies of Austria, Styria and Carinthia from the Bohemian king Ottokar II. After King Ottokar was defeated and killed in the 1278 Battle on the Marchfeld, King Rudolf in December 1282 vested his sons Albert and Rudolf II with the Austrian and Styrian duchies. However, in the Treaty of Rheinfelden on 1 June 1283 Rudolf II had to relinquish his share in favour of his elder brother Albert.