In existence since the 15th century, it received its city charter around 1727. In 1772 it became part of the Habsburg Monarchy where it remained until 1918 when it became part of independent Poland. It grew after 1872 when a railway connection to Przemyśl and Sanok was built, and the exploitation of local oil fields began. Temporarily in the USSR after 1944, it became part of Poland in 1951 following a minor border readjustment.