In the Middle Ages, Lviv was an important economic, cultural and political center of Ruthenia. Its history covers the period from the foundation of the fortress in the mid-13th century to the second half of the 16th century, when the Polish–Lithuanian Commonwealth was formed and the Jagiellonian dynasty was interrupted. The first written mention of Lviv dates back to 1256. From the 2nd half of the 13th century it was one of the largest cities of the Kingdom of Galicia–Volhynia, after 1341 — the center of the "Ruthenian Kingdom" within Poland. In 1370, Lviv was ceded to the Kingdom of Hungary, and in 1387, it returned to the Kingdom of Poland. After 1433, Lviv became the administrative center of the Ruthenian Voivodeship. The population of the medieval city was characterized by multi-ethnicity and multi-confessionalism, which often led to friction and open conflict between different communities.

History According to archaeological excavations, the territory of modern Lviv and its immediate surroundings was inhabited as early as the Mesolithic period. In particular, several ancient settlements, including a cave settlement, as well as stone products of the Vorotsev-Starunya culture (6th–4th millennium BC) were found on the territory of modern Bryukhovichi. From the end of the Copper Age (3rd millennium B.C.), traces of settlements of agricultural and pastoral tribes were discovered by archaeologists on Zamkova Hora, as well as on the hills of Lysovka, Zhupan and Chortovi Skeli near the town of Vynnyky (these settlements are attributed to the funnelbeaker culture). On the territory of the modern Ivan Franko Park there is a burial mound from the beginning of the Bronze Age.История городов и сёл Украинской ССР в 26 томах. Львовская область [History of cities and villages of the Ukrainian SSR in 26 volumes. Lviv region] (in Russian). Киев: Украинская советская энциклопедия. 1978. pp. 87-88.

In 1992, during excavations in the area of today's Dobrobut Market (former suburb of Kraków, today's Knyaz Jarosław Osmomysła Square), traces of settlements of the Hallstatt culture (mid 1st millennium BC), Chernyakhov culture (4th century), Prague culture (6th century) and Luka-Raikovetska culture (8th–9th century) were discovered. Traces of a Hallstatt settlement were found in Teatralna Street in 1986 and in Ivan Pidkova Square in 1987.ТОП-7 археологічних знахідок у Львові за 2015 рік. (12 February 2016).

The oldest permanent Slavic settlements on the Lviv's modern territory of were located between the Poltva River valley and the Znesinnia Hills. In the territory of today's Znesinnia Park, namely on the top of Snake Mountain, in the 7th–10th centuries there was a pagan temple of the god Svetovit, near which there was a large hillfort (today this area is known as Svyatovitov's Field). On the neighboring Baba Mountain (also known as the Rod Mountain), traces of a temple and a settlement from the same period were discovered. It has been established that in the 10th century these settlements moved to the western slope of Zamkova Mountain and most of the old settlement was demolished. After that, the area was given the name Znesinnia, which is the oldest Lviv toponym of Slavic origin.Регіональний ландшафтний парк «Знесіння». Львівська міська рада. (17 September 2014).Traces of another ancient settlement, apparently from the 11th century, were found in the Ivan Franko Park. Additionally, in Lviv and the nearest suburbs there are numerous traces of the temples of Perun, Rod, Rozhanitsy and Veles. Writing developed in the area of modern Lviv, as evidenced by birch-bark letters found in 1988–1989 in Zvenyhorod and dated to the first third of the 12th century (these are the only birch-bark letters found in Ukraine).

Kingdom of Galicia–Volhynia

Lviv was first mentioned in the Galician–Volhynia Chronicle in connection with a fire in Chełm in fall of 1256. The founder of the city is considered to be Prince Daniel Romanovich, who named it after his son Leo.История городов и сёл Украинской ССР в 26 томах. Львовская область [History of cities and villages of the Ukrainian SSR in 26 volumes. Lviv region] (in Russian). Киев: Украинская советская энциклопедия. 1978. P. 88. However, contemporary sources do not confirm this. Leontii wójtovich, for example, considers Lev Danilovich to be the founder, which is supported by the data of the annals of the 16th-18th centuries.Лев Данилович: «князь думен и хоробор на рати» чи «безчесний князь»? К.: Інститут історії України НАН України, 2013. Issue. 12-13. pp. 148—189. In 1245, Leo commanded a separate regiment, which indicates the existence of an appanage.Voytovich L. Король Данило Романович: політик і полководець. Доба короля Данила в науці, мистецтві, літературі. Львів, 2008. pp. 22-97.

1980s restoration work, revealed the remains of oak buildings dating from 1213. The city may have been founded after the Mongol raid 1239 to rebuild the economy, or in honor of Leo's marriage to Constance, daughter of Bela IV (1247).In 1259 or 1261, the Mongol general Boroldai forced the destruction of the wooden Lviv castle on Zamkova Hill. According to the version of researchers, the Detinets was located either on the Zamkova Hill or in the place of Znesinnia. In 1270–1280, Lviv became the capital of the Princedom, the city's coat of arms was used as the state symbol. In 1288, the castle withstood the siege of Telebuga Khan. Archaeologists discovered the remains of a round tower, a stone wall and an earthen rampart.Історія Львова в документах і матеріалах [The history of Lviv in documents and materials] (in Ukrainian). Київ: Наукова думка. 1986. pp. 10-11.

In the 13th–14th centuries, Lviv was a major city of the principality and had a coat of arms with the image of a lion. The princes' palace was located on the site of today's Dominican monastery.История городов и сёл Украинской ССР в 26 томах. Львовская область [History of cities and villages of the Ukrainian SSR in 26 volumes. Lviv region] (in Russian). Киев: Украинская советская энциклопедия. 1978. P. 89. In 1340, Prince Yuri II was poisoned, causing unrest. The Polish king Casimir III took advantage of this and seized Lviv, but the city was repulsed by the Tatars and citizens led by Dmytro Dedko.История городов и сёл Украинской ССР в 26 томах. Львовская область [History of cities and villages of the Ukrainian SSR in 26 volumes. Lviv region] (in Russian). Киев: Украинская советская энциклопедия. 1978. pp. 88-89. In 1349, Casimir retook Lviv and made it the center of the "Ruthenian Kingdom".Історія Львова в документах і матеріалах [The history of Lviv in documents and materials] (in Ukrainian). Київ: Наукова думка. 1986. pp. 133—134. In the 14th century, Lviv became the economic center of the principality, but not an important political or cultural center. Due to German colonization, a significant group of burghers was formed here, governed by city law.

Polish kingdom

In the summer of 1352, Casimir III granted large estates to the children of the Lviv wójt Berthold, and also confirmed the rights of the Galician boyars and obliged them to military service. Wojts and schultheisses were also obliged to military service. On his order, the High Castle was rebuilt: stone walls, towers, two courtyards and a palace appeared.

In 1356, Lviv became self-governated under the Magdeburg rights.Elements of Magdeburg law, such as the position of a voyt, were also present in the princely period. It is therefore believed that the royal charter of 1356 confirmed the status quo rather than introducing Magdeburg law from scratch. After the Casimir III's death in 1370, the city went to Hungary. Vladyslaus Opolczyk gave the Armenians the Church of the Holy Cross and allocated funds for monasteries. In 1381, a fire destroyed the town hall, the lower castle and the archive.

In 1387, Jadwiga returned Lviv to Poland. Vladyslaus II promised not to give the city to the feudal lords. The Polish authorities granted privileges to Catholics, to the detriment of Ruthenians and Jews. By the end of the 14th century, Polish and German settlers had become a wealthy patriciate. Vladyslaus II granted Armenians the right to trade in Poland in 1402.In 1410, in Lviv Vladyslaus II developed the plan of a campaign against the Teutonic Order. After the battle of Grunwald (1410) the city met him triumphantly. In 1415, the king granted Lviv lands for the foundation of villages. In 1434, Galicia became part of Poland, becoming the Ruthenian Voivodeship. Polonization and ocatholization accelerated.

In 1489, Polish troops passed through Lviv on their way to Wallachia. The fires of 1494, 1498, and 1524, caused considerable damage to the city. In 1509, the Moldavian lord Bogdan III besieged Lviv, but Polish troops defeated his army.

In 1527, a fire destroyed the city's Gothic architecture, forcing a major reconstruction. In 1539, an Orthodox archbishopric was established in Lviv. In the 16th century, the suburbs and urban villages grew, mainly due to the influx of craftsmen.

In 1559, a conflict broke out in the city over Princess Elzaveta Ostrogska. In 1578, Ivan Pidkova, a pretender to the Moldavian throne, was executed. In 1586, Patriarch Joachim V blessed the charter of the Brotherhood of the Holy Night. At the end of the 16th century, Lviv became an important cultural and religious center.

Urban development and planning

In the Middle Ages, Lviv consisted of two castles: the High Castle on the Zamkova Hill and the Low Castle in the Poltva River valley, where Vicheva Square is located nowadays. The city was surrounded by fortress walls with gates and towers. To the northeast, Lviv was bordered by the village of Zneseniye, and to the west and south by the Poltva and Paseka rivers. The city center (roundabout) was located on the western slope of Zamkova Hill, from Old Market Square to Pidzamche. There were about ten Orthodox churches among the dense buildings. The city was bordered by suburbs (posady). In the late 14th and early 15th centuries, the new city center, inhabited by German burghers and Catholic nobility, was surrounded by a stone wall with towers, gates, and a moat with water. The modern boundaries of the medieval center include Svobody Avenue, Mickiewicz Square, Halytska Square, Soborna Square, Vynnychenka Street, and Mytna Square. In the center was the Market Square with the City Hall, and Ruthenians, Armenians, and Jews lived in separate quarters. The former city center gradually fell into disrepair and became the Zhovkva suburb. To the west and south of the center were the Krakiv and Galicia suburbs, and to the east — the Lychakiv suburb.

Zneseniye was owned by Polish kings who leased it. In 1356, Casimir III granted Lviv 70 Frankish lans, and in 1368, he increased the territory by 30 lans. By the end of the 14th century, the city had expanded considerably due to settlers from Western Europe and neighboring countries.

The fortifications of the city included two main gates: the Galician Gate and the Krakow Gate. The Galician Gate, located at the intersection of today's Halytska and Brativ Rohatyntsiv Streets, protected the entrance to the city from Galicia and Hungary. The Krakow Gate, located at the intersection of Krakowska and Lesya Ukrainka Streets, controlled the entrances from Krakow and Lutsk. The city's defensive walls consisted of the High Wall, completed in the first half of the 15th century, and the Low Wall with bastions.

After the fire of 1527, which destroyed many parts of the city, the authorities rebuilt the fortifications. New towers were built on the southern and eastern parts of the city walls. At that time, Lviv had three lines of defense: the High Wall with towers, the Low Wall with bastions, and the earthen ramparts, culminating in the construction of the Powder Tower. In the 16th century, additional bastions and fortifications were built.