ANKARA (Reuters) - Iran accused Turkey on Tuesday of prolonging the three-year conflict in neighboring Syria by insisting on President Bashar al-Assad's overthrow and supporting "terrorist groups" in Syria, the official IRNA news agency reported.

Tehran and Ankara back opposing sides in the civil war, which pits rebel forces including radical Sunni Muslim fighters from the Islamic State against Assad, Tehran's closest regional ally.

Turkey, which has called for Assad to step down, has been a main transit point for foreign militants crossing into Syria to fight his forces, while Iran has supported him both militarily and politically.

"Ankara’s interference in Syrian internal affairs has unfortunately resulted in prolonging the war and extensive deaths of innocent Syrian civilians," Iran's official IRNA news agency quoted a senior Foreign Ministry official as saying.

"The crisis in Syria could have ended three years ago if Turkish officials stopped demanding regime change and supporting terrorist groups in Syria," the official said.

The comments appeared to be a response to remarks by Turkish President Tayyip Erdogan, who was quoted by Turkish media on Monday accusing Iran of playing on Syria's sectarian divisions.

"When we have bilateral meetings with Iran, they agree on solving this issue together. When it comes to action, unfortunately, they have their own way of working," Erdogan was quoted by the Hurriyet newspaper as saying.

The Syrian conflict has undermined what were once close ties between Iranian officials and Erdogan, whose Syria policy has put him at odds with Iran, Russia and, at times, the United States.

NATO-member Turkey has refused to join the U.S.-led military coalition against the Islamic State unless it also confronts Assad, a demand that Washington, which flies air missions over Syria without objection from Damascus, has so far rejected.

Iran and the United States have been arch-foes for decades but now share a strategic interest in reversing the territorial gains of IS that threaten to redraw the map of the Middle East.

Story continues

The military gains by Islamic State fighters challenge Tehran’s strategy of projecting power from the Gulf to the Mediterranean through its mainly Shi'ite allies in Iraq, Syria, and Lebanon.

Tehran has blamed the West for the rise of Islamic State, which controls swathes of Syria and Iraq, but also suggested the need for common action in confronting the group.

(Writing by Parisa Hafezi; Editing by Dominic Evans)