The city of Vilnius, the capital and largest city of Lithuania, has an extensive history starting from the Stone Age. Vilnius was the head of the Grand Duchy of Lithuania until 1795, even during the Polish–Lithuanian Commonwealth. The city has changed hands many times between Imperial and Soviet Russia, Napoleonic France, Imperial and Nazi Germany, Interwar Poland, and Lithuania. It was especially often the site of conflict after the end of World War I and during World War II. It officially became the capital of independent, modern-day Lithuania when the Soviet Union recognized the country's independence in August 1991.
The earliest settlements in the area of present-day Vilnius appear to be of mesolithic origin. Numerous archaeological findings in different parts of the city prove that the area has been inhabited by peoples of various cultures since the early Middle Ages. Initially a Baltic settlement, later it was also inhabited by Slavs, Jews and Germans. Some historians identify the city with Voruta, a forgotten capital of King Mindaugas.
The city was first mentioned in written sources as Vilna in 1323 as the capital city of the Grand Duchy of Lithuania in the letters of Gediminas. Gediminas built his wooden castle on a hill in the city. The city became more widely known after he wrote a circular letter of invitation to Germans and Jews to the principal Hansa towns in 1325, offering free access into his domains to men of every order and profession. Gediminas founded first Dominican monastery in 1321. In the second half of the century church of St. Nicholas was erected. At this time Vilnius was facing numerous raids of the Teutonic Order, although they never captured the castle, large portions of the town were burned down in years 1365, 1377 and 1383.
Vilnius was granted city rights by Jogaila in 1387, following the Christianization of Lithuania and the construction of the Vilnius Cathedral. The town was initially populated by local Lithuanians, but soon the population began to grow as craftsmen and merchants of other nationalities settled in the city.