Lviv (Ukrainian: , L’viv; ; (archaic); ; , see also other names) is an administrative center in western Ukraine with more than a millennium of history as a settlement, and over seven centuries as a city. Prior to the creation of the modern state of Ukraine, Lviv had been part of numerous states and empires, including, under the name Lwów, Poland and later the Polish–Lithuanian Commonwealth; under the name Lemberg, the Austrian and later Austro-Hungarian Empires; the short-lived West Ukrainian People's Republic after World War I; Poland again; and the Soviet Union. In addition, both the Swedes and the Ottoman Turks made unsuccessful attempts to conquer the city.

Early history

Prehistory Traces of settlement in the area of Lviv date back to the Mesolithic period (the region of the ). The continuity of settlement in the area of Lviv’s Old Town goes back to the 5th–6th centuryЯ. Ісаєвич, М. Литвин, Ф. Стеблій / Iсторія Львова. У трьох томах (History of Lviv in Three Volumes). Львів : Центр Європи, 2006. – Т. 1, p7. ., while traces of settlement on Castle Hill date back to the 10th century, when a fortified settlement was established on the westernmost rise of Castle Hill, known as Bald Mountain, when the earliest stronghold was erected. The original name of the Bald Mountain settlement was probably Elevation/Rise in the Ruthenian language. The political affiliation of the area before the emergence of the medieval city of Lviv is less certain. The wider region changed hands between the Piast and Rus' rulers in the 10th and 11th centuries.

In 981, the Cherven Cities were conquered by Volodymyr the Great and came under the rule of Kyivan Rus, after the Kyiv expedition he again began in the early Piast monarchy of Bolesław the Brave and Mieszko II (1018–1031), and then occupied by the prince of Kyiv, Yaroslav the Wise in 1031.

The foundation of the princely town Lviv is mentioned as a separate town only from the mid-13th century. The first mention of it appears in sources from 1259. Another source from 1261 states that the city’s fortifications were demolished at the Tatars’ demand, which indicates that it must already have been a fairly significant urban centre. Therefore, the origins of a town are usually dated to the first half of the 13th century. Most likely, after the Mongol invasion, it was rebuilt in 1241–1242 on the basis of an earlier settlement, with the layout reorganized and rights granted to settlers arriving from the West.

The rebuilding and new foundation of the town was most likely carried out by Daniel, Duke of Halych, subordinate to the Golden Horde and ruling the land from his capital in Chełm. He renamed the city in honour of his son Lev, who at that time was the duke of Belz.Orest Subtelny. (1988) Ukraine: A History. Toronto: University of Toronto Press, p. 62 The toponym may best be translated into English as Leo's lands or Leo's City (hence the Latin name Leopolis). It is not clear how extensive the destruction caused by the Tatars in 1261 was; it is possible that Lviv had to be rebuilt almost from scratch.

The town was founded at the foot of the hill on which the ducal defensive stronghold was built. It had a quadrilateral layout, bounded on the west by the Poltva River and on the south by the Ortysha stream. Its centre was an irregular market square stretching southward from the ; its remnant is today’s Old Market Square. The church became the main Orthodox and princely church, and it was also one of the few masonry buildings in Lviv at that time. From the very beginning, the town had a multi-ethnic character; apart from Ruthenians, it was inhabited by Germans, Jews, Tatars and Karaites. The Germans played an important role, the German name of the town (Lamburga) appears in ducal documents. They also owned the Catholic Franciscan . The second Catholic church was the Church of St John the Baptist, founded around 1270 at the request of Constance of Hungary, the wife of Lev of Halych. The Armenians also constituted a significant part of the population; around 1283 they built, outside the town walls, a church of their own rite dedicated to St Anne. The early town of Lviv was almost entirely built of wood, including its fortifications. Around the year 1300 it had twelve churches: eight Orthodox, two Catholic, and two Armenian.

After Daniel's death, Lev rebuilt Lviv around the year 1270. By choosing Lviv as his residence,Meyers Konversations-Lexikon. 6th edition, vol. 12, Leipzig and Vienna 1908, p. 397-398. Lev made Lviv the capital of Galicia-Volhynia.B.V. Melnyk, Vulytsiamy starovynnoho Lvova, Vyd-vo "Svit" (Old Lviv Streets), 2001,

In 1323 the Romanovich dynasty, a local branch of the Rurik Dynasty, died out. The city was inherited by Boleslaus of Masovia the heir to both the Piast dynasty on his father's side, and the Romanovich dynasty on his mother's side. He took the name of "Yuriy" and converted to Eastern Orthodoxy but failed to gain the support of the local nobles and was eventually poisoned by them in 1340.

Galicia–Volhynia wars King Casimir the Great of Poland asserted his succession rights, and as the closest relative of the deceased prince he launched two expeditions into Rus’ in 1340, supported by Hungary. During one of them, according to Polish annals, he captured and burned Lviv, carrying off the merchants and the ducal treasure. The reaction to Casimir’s raid was a retaliatory expedition by the Golden Horde, the overlord of the Galicia principality, into Poland in 1341, as well as a rebellion by the administrator of Przemyśl, Dmytro Dedko. Casimir repelled the Tatar incursion and came to an understanding with Dmytro, who thereafter governed Galicia in his name.

After Dedko's death King Casimir III entered Red Ruthenia and established direct rule there in 1349. In the course of his clashes with the Lithuanians, Casimir managed to consolidate his authority over the Lviv land, while Lithuanians controlled northern part of the principality. In 1350 he concluded an agreement with King Louis of Hungary that, should Casimir’s son inherit the Polish crown, Hungary would be allowed to buy back Rus’ from Poland for 100,000 florins. In 1353 the Lithuanians raided and destroyed Lviv.

Casimir’s retaliatory campaign of 1355 ended in success and in the imposition of his suzerainty over the Lithuanian princes in Volhynia. A sign of the consolidation of peace and of Casimir’s authority was the granting in 1356 of a location charter for Lviv under Magdeburg law.

Kingdom of Poland

City of Casimir the Great

Lviv became the capital of the Ruthenian lands under Casimir’s rule, who appointed his own starosta there, Otton of Pilcza, no later than in 1352. Later, starostas appeared in other towns as well, but the one in Lviv had precedence over them, bearing the title capitaneus terrae Russiae. The king encouraged the influx of Polish nobles, to whom he granted estates in the region, as well as the arrival in the towns of Germans, Jews, and Armenians.

In 1356 Casimir III imparted upon the city with Magdeburg rights, which implied that all city issues were to be resolved by a city council elected by the wealthy citizens. The city council seal of the 14th century stated Civitatis Lembvrgensis. This started a period of accelerated development: among other facilities the Latin Cathedral was built, around the same time a church was built in the place of today's St. George's Cathedral. Also, new self-government led to the greater growth of the Armenian community that built its Armenian Cathedral in 1363.

The presence of the Latin Church was also strengthening. Formally, the lands of the Halych principality were subject to the bishop of Lubusz, and there already existed a bishopric in Przemyśl, founded by Prince Yurii Boleslav. In 1358–59 the king brought about the creation of titular bishoprics in Chełm, Volodymyr, and Lviv. The last of these was entrusted to the Dominicans. In 1367 a Latin archdiocese was established in Halych, to which all the Ruthenian bishoprics were subordinated. It is very likely that from the beginning there were plans to move its seat to Lviv, since around 1360 Casimir III began the construction of a large cathedral church, near the new market square. However, this transfer did not actually take place until 1412.

After Casimir had died in 1370, he was succeeded by his nephew, King Louis I of Hungary, who in 1372 put Lviv together with the region of Galicia-Volhynia under the administration of his relative Władysław, Duke of Opole. When Władysław retreated from the post of its governor in 1387 Galicia-Volhynia became occupied by the Hungarians, but soon Jadwiga the ruler of Poland, and wife of Lithuanian Grand Duke Jogaila, incorporated it into the Polish Crown.

Polish–Lithuanian Commonwealth

As a part of Poland the city was a capital of the Ruthenian Voivodeship, which included five regions: Lwów, Chełm, Sanok, Halych and Przemyśl. The city was granted the right of transit and started to gain significant profit from the goods transported between the Black Sea and the Baltic. Lviv became an important commercial centre, with a prosperous merchant class composed mainly of Armenians, Greeks, and Levantine Italians. Its trade connections were maintained primarily with the East, Hungary, from which wine was imported, and Gdańsk. The city developed into a multiethnic community. Its inhabitants were divided into several nationes distinguished largely by religion: Polish (Roman Catholic), Ruthenian (Eastern Orthodoxy), Armenian (Armenian Apostolic), and Jewish. Protestant denominations were not tolerated in Lviv, and consequently their presence in the city remained negligible. In 1586, Pope Sixtus V rewarded the city for its loyalty to the Catholic faith by augmenting its coat of arms with three hills surmounted by a star, taken from his own arms.

The city's fortifications were strengthened, with Lviv becoming one of the most important fortresses guarding the Commonwealth from the south-east. Three archbishoprics were once located in the city: Roman Catholic (est. 1375), Greek Catholic and Armenian Catholic. The city was also home to numerous ethnic populations, including Germans, Jews, Italians, Englishmen, Scotsmen and many others. Since the 16th century, the religious mosaic of the city also included strong Protestant communities. By the first half of the 17th century, the city had approximately 25,000–30,000 inhabitants. About 30 craft organizations were active by that time, involving well over a hundred different specialities.

Decline of the Commonwealth

In the 17th century Lviv was besieged unsuccessfully several times. Constant struggles against invading armies gave it the motto Semper fidelis. In 1648, the city was besieged by the Cossacks under Bohdan Khmelnytsky, who seized and destroyed the local castle. However, the Cossacks did not retain the city and withdrew, satisfying themselves with a ransom. In 1655 the Swedish armies invaded Poland and soon took most of it. Eventually the Polish king Jan II Kazimierz solemnly pronounced his vow to consecrate the country to the protection of the Mother of God and proclaimed Her the Patron and Queen of the lands in his kingdom at Lwów Latin Cathedral in 1656 (Lwów Oath).

The Swedes laid siege to Lviv, but were forced to retreat before capturing it. The following year saw Lviv invaded by the armies of the Transylvanian Duke George I Rákóczi, but the city was not captured. In 1672 Lviv was again besieged by the Ottoman army of Mehmed IV, however the Treaty of Buczacz ended the war before the city was taken. In 1675 the city was attacked by the Ottomans and the Tatars, but King John III Sobieski defeated them on 24 August in what is called the Battle of Lwów. In 1704, during the Great Northern War, the city was captured and pillaged for the first time in its history by the armies of Charles XII of Sweden.

Habsburg Era

18th century