Kęstutis, Duke of Trakai, despite exercising considerable autonomy while controlling the western provinces of the duchy, was loyal to Algirdas and acknowledged his superiority. Kęstutis was a devoted pagan and dedicated his life to defending Lithuania from the Teutonic Knights. A popular romantic legend arose about his marriage to the pagan priestess Birutė of Palanga. They had seven or eight children, including Vytautas the Great. After Algirdas' death in 1377, his son Jogaila became the Grand Duke. At first Kęstutis and his son Vytautas acknowledged Jogaila's rule, but after Jogaila signed the controversial Treaty of Dovydiškės with the Teutonic Knights, Kęstutis seized Vilnius and became the Grand Duke in late 1381. In August 1382 he was imprisoned in Kreva and died there. Vytautas continued his fight for supremacy, and the conflicts between the descendants of Algirdas and Kęstutis lasted well into the 15th century.