Piemare
The original settlement at the location of modern Liep?ja was founded by Curonian fishermen of Piemare and was known by the name L?va (from the name of the river L?va on which Liep?ja was located, which in turn originated from the Livonian word Liiv meaning "sand"). The oldest written text mentioning the name is dated 4 April 1253. The Livonian Order under the aegis of the Teutonic Order established the settlement as the village of Liba(u) in 1263. In 1418 the city was sacked and burned by the Lithuanians. During the 15th century, a part of the trade route from Amsterdam to Moscow passed through L?va and it was known as the "white road to Lyva portus". By 1520 the river L?va had become too shallow for easy navigation, and this negatively influenced on the development of the city.
Duchy of Courland and Semigallia
In 1560, Gotthard Kettler loaned all the Grobi?a district including Liep?ja to Albert, Duke of Prussia for 50,000 guldens. Only in 1609 after the marriage of Sofie Hohenzollern, princess of Prussia, to Wilhelm Kettler did the territory return to the Duchy. During the Livonian War, Liep?ja was attacked and destroyed by the Swedes. In 1625, Duke Friedrich Kettler of Courland granted the town city rights, which were affirmed by King Sigismund III of Poland in 1626. The name Liep?ja was mentioned for the first time in 1649 by Paul Einhornin his work "Historia Lettica". Under Duke Jacob Kettler (1642�1681), Liep?ja became one of the main ports of Courland as it reached the height of its prosperity. In 1637 Courland colonization was started from the ports of Liep?ja and Ventspils. Jacob was an eager proponent of mercantilist ideas. Metalworking and ship building became much more developed and trading relations developed not only with nearby countries, but also with Britain, France, the Netherlands and Portugal. In 1697�1703 a canal was cut to the sea and a port was built. In 1701, during the Great Northern War, Liep?ja