The oldest known mention of Leśnica comes from a 1217 document of Duke Casimir I of Opole. Its name is derived from the Polish word "las" ("forest"). The town was part of the Duchy of Opole of fragmented Poland, and remained ruled by the Piast dynasty until 1532. The town was destroyed in 1429 during the Hussite Wars. In 1532 incorporated into the Bohemian Crown Lands, in 1645 it passed to the Poles again under the House of Vasa, and in 1666 it fell back to Bohemia.