When the Holy Roman Empire ended in 1806 , the Margraviate of Baden became the larger and more powerful Grand Duchy of Baden . It came into existence in the 12th century as the Margraviate of Baden and subsequently split into different lines , which were unified in 1771 . It became the much-enlarged Grand Duchy of Baden through the dissolution of the Holy Roman Empire in 1803 â `` 06 and remained a sovereign country until it joined the German Empire in 1871 , remaining a Grand Duchy until 1918 when it became part of the Weimar Republic as the Republic of Baden .