Turkey’s president has warned that he would evict U.S. forces from two military bases in his country if Washington imposes new sanctions on his government—creating a quandary for the NATO alliance as it seeks to cope with Ankara’s deepening ties to Russia.

In a television interview this month, President Recep Tayyip Erdogan said if the U.S. punishes Turkey for its purchase of a Russian air-defense system, then, “if necessary, we may close Incirlik and Kurecik,” installations where the U.S. keeps nuclear weapons and operates...