In 1627 during the Thirty Years' War, the town was rebuilt after being destroyed by a fire. When the Pomeranian dukes died out in 1637 Bytów ceased to be a Polish fief and became directly ruled by Poland, administratively part of the Pomeranian Voivodeship. Then the local nobility obtained equal rights with the nobility of the entire Polish–Lithuanian Commonwealth. Bytów was overshadowed by Lębork, which developed faster and became the seat of local starosts. In 1651 there was a dispute between the city authorities and the starost Jakub Wejher, regarding overdue taxes. To gain an ally against Sweden during the Deluge, in 1657 King John II Casimir of Poland gave the Lauenburg and Bütow Land to Margrave Frederick William of Brandenburg-Prussia as a hereditary fief in the Treaty of Bydgoszcz. Although Poland still retained sovereignty, the town was administered by Brandenburg and, after 1701, by the Kingdom of Prussia. Brandenburg imposed higher taxes to pay off its debts after the Thirty Years' War. During the 18th century, the town suffered from fires and plague.