With the collapse of the Safavid Empire in 1722, the Caucasian provinces were thrown into chaos. The Ottomans and Russians seized this opportunity to invade, with Peter the Great invading in the summer of 1722 and capturing Derbent. The Ottomans invaded in the summer of 1723, and had taken all of Persia's caucasian provinces by 1725. However, the tribal groups of Azerbaijan resisted heavily.