The Free State of Bavaria, is a state of Germany, located in the southeast of Germany. With an area of 70,548 square kilometres (27,200 sq mi), it is the largest state by area, forming almost 20% of the total land area of Germany. Bavaria is Germany's second most populous state (after North Rhine-Westphalia), with 12.5 million inhabitants, more than any of the three sovereign nations on its borders. Bavaria's capital and largest city is Munich, the third largest city in Germany. One of the oldest states of Europe, it was established as a duchy in the mid first millennium. In the 17th century, the Duke of Bavaria became a Prince-elector of the Holy Roman Empire of the German Nation. The Kingdom of Bavaria existed from 1806 to 1918, and Bavaria has since been a free state (republic). Modern Bavaria also includes parts of the historical regions of Franconia, Upper Palatinate and Swabia.