ANKARA/SOCHI (Reuters) - Turkish President Tayyip Erdogan took swipes at U.S. and Russian interventions in Syria on Monday and said if countries truly believed a military solution was impossible, they should withdraw their troops.

Turkish President Tayyip Erdogan and his Russian counterpart Vladimir Putin attend a news conference in Sochi, Russia, November 13, 2017. Yasin Bulbul/Presidential Palace/Handout via REUTERS

Russian President Vladimir Putin and his U.S. counterpart Donald Trump said in a joint statement on Saturday they would continue to fight against Islamic State in Syria, while agreeing that there was no military solution to the country’s wider, six-year-old conflict.

“I am having trouble understanding these comments,” Erdogan told reporters before flying to Russia for talks with Putin. “If a military solution is out of the question, then those who say this should pull their troops out.

“Then a political method should be sought in Syria, ways to head into elections should be examined... We will discuss these with Putin,” he said.

After more than four hours of talks with Putin in the southern Russian resort of Sochi, Erdogan said the two leaders had agreed to focus on a political solution to the conflict.

“We agreed that the grounds to focus on a political solution (in Syria) have been formed,” he said.

Putin said Russia would continue to work on Syria with Turkey and their efforts were yielding results: “The level of violence has definitely been reduced, favorable conditions are being created for the progression of a inter-Syrian dialogue.”

Neither leader went into more specific detail. Asked if the two discussed Erdogan’s earlier comments, Kremlin spokesman Dmitry Peskov said the talks were about more complex issues which could not be made public, according to RIA news agency.

Turkey has been annoyed by both Russian and U.S. missions in Syria. Before his trip to Russia, Erdogan said both Moscow, which backs President Bashar al-Assad, and Washington, which armed Syrian YPG Kurdish forces Ankara sees as allied to separatists fighting in southeastern Turkey, had set up bases.

“The United States said it would completely leave Iraq, but it didn’t. The world is not stupid, some realities are being told differently and practiced differently,” he said.

He said the United States had 13 bases in Syria and Russia had five. The YPG has said Washington has established seven military bases in areas of northern Syria. The U.S.-led coalition says it does not discuss the location of its forces.

Russia has been a strong supporter of Assad, whose removal Erdogan has demanded, and Moscow’s military intervention two years ago helped turn the conflict in the Syrian president’s favor.

Turkish troops have also fought in Syria to halt the advance of Kurdish YPG forces along its frontier.

Slideshow ( 6 images )

“We attach great importance to the joint steps Turkey and Russia will take on (the) defense industry,” Erdogan said.

His remarks follow Turkey’s recently completed purchase of Russian S-400 surface-to-air missile systems, a defense deal that Turkey’s Western allies see as a snub to the NATO alliance.

The weapon cannot be integrated into NATO defenses.

Ankara says it is making agreements with the Franco-Italian EUROSAM consortium to develop, produce and use its own sources for air defense system.