The first settlements in the region of modern Grajewo already existed in the early 15th century. The first documented mention is from the year 1426. In the late 15th century the village was a small center of trade and crafts. In 1540 the town obtained municipal rights from Polish King Sigismund I the Old. In 1656, during the Deluge (Polish-Swedish war), the Battle of Prostki took place nearby. The town's population decreased dramatically as a result of the war. In 1692 the town came into possession of the Wilczewski family, hailing from Wilczewo. In 1794 battles of the Polish Kościuszko Uprising were fought near Grajewo. In 1777, the town had 258 inhabitants, and in 1800 it had 218 inhabitants.