It was soon restored under the Turkman tribe of the Qara Qoyunlu, who established a short-lived local dynasty. Under the Safavids it rose from regional to national capital for a short period, but the second of the Safavid kings, Shah Tahmasb, moved the capital to Qazvin because of the vulnerability of Tabriz to Ottoman attacks. The town then went into a period of decline, fought over by the Iranians, Ottomans and Russians and struck by earthquake.