One of the events that greatly contributed to the city's development was the Polish-Lithuanian Union of Krewo in 1385. Lublin thrived as a centre of trade and commerce due to its strategic location on the route between Vilnius and Kraków; the inhabitants had the privilege of free trade in the Grand Duchy of Lithuania. The Lublin Parliament session of 1569 led to the creation of a real union between the Crown of the Kingdom of Poland and the Grand Duchy of Lithuania, thus creating the Polish-Lithuanian Commonwealth. Lublin witnessed the early stages of Reformation in the 16th century. A Calvinist congregation was founded and groups of radical Arians appeared in the city, making it an important global centre of Arianism. At the turn of the centuries, Lublin was recognized for hosting a number of outstanding poets, writers and historians of the epoch.
Until the partitions at the end of the 18th century, Lublin was a royal city of the Crown Kingdom of Poland. Its delegates and nobles had the right to participate in the Royal Election. In 1578 Lublin was chosen as the seat of the Crown Tribunal, the highest appeal court in the Polish–Lithuanian Commonwealth, and for centuries the city has been flourishing as a centre of culture and higher learning, with Kraków, Warsaw, Poznań and Lwów.
Although Lublin was not spared from severe destruction during World War II, its picturesque and historical Old Town has been preserved. The district is one of Poland's official national Historic Monuments (Pomnik historii), as designated May 16, 2007, and tracked by the National Heritage Board of Poland.
The city is viewed as an attractive location for foreign investment and the analytical Financial Times Group has found Lublin to be one of the best cities for business in Poland. The Foreign Direct Investment ranking (FDI) placed Lublin second among larger Polish cities in the cost-effectiveness category. Lublin is noted for its green spaces and a high standard of living.
Archaeological finds indicate a long presence of cultures in the area. A complex of settlements started to develop on the future site of Lublin and in its environs in the 6th-7th centuries. Remains of settlements dating back to the 6th century were discovered in the center of today's Lublin on Czwartek ("Thursday") Hill.
The period of the early Middle Ages was marked by intensification of habitation, particularly in the areas along river valleys. The settlements were centered around the stronghold on Old Town Hill, which was likely one of the main centers of Lendians tribe. When the tribal stronghold was destroyed in the 10th century, the center shifted to the northeast, to a new stronghold above Czechówka valley and, after the mid-12th century, to Castle Hill. At least two churches are presumed to have existed in Lublin in the early medieval period. One of them was most probably erected on Czwartek Hill during the rule of Casimir the Restorer in the 11th century. The castle became the seat of a Castellan, first mentioned in historical sources from 1224 but was quite possibly present from the start of the 12th or even 10th century. The oldest historical document mentioning Lublin dates from 1198, so the name must have come into general use some time earlier.
The location of Lublin at the eastern borders of the Polish lands gave it military significance. During the first half of the 13th century, Lublin was a target of attacks by Mongols, Ruthenians and Lithuanians, which resulted in its destruction. It was also ruled by Kingdom of Galicia–Volhynia between 1289 and 1302. Lublin was founded as a town by Władysław I the Elbow-high or between 1258 and 1279 during the rule of prince Bolesław V the Chaste. Casimir III the Great, appreciating the site's strategic importance, built a masonry castle in 1341 and encircled the city with defensive walls. From 1326, if not earlier, the stronghold on Castle Hill included a chapel in honor of the Holy Trinity. A stone church dated to the years 1335-1370 exists to this day.