In the late Middle Ages, Lesser Poland gradually became the center of Polish statehood, with Kraków being the capital of the country from the mid-11th century until 1596. Its nobility ruled Poland when Queen Jadwiga was too young to control the state, and the Union of Krewo with the Grand Duchy of Lithuania was the brainchild of Lesser Poland's szlachta.