WASHINGTON (Reuters) - U.S. President Barack Obama and Turkish President Tayyip Erdogan agreed in a telephone call on Wednesday to work together to "stem the flow of foreign fighters and secure Turkey's border with Syria," the White House said in a statement.

It said the two leaders also discussed deepening their cooperation in the fight against Islamic State, which has grabbed swaths of Syrian and Iraqi territory and declared a caliphate.

Thousands of foreign fighters have crossed through Turkey, a NATO member, to join Islamic State over the past few years.

The Turkish government has rejected accusations from the opposition that it has in the past tacitly supported Islamic State militants operating from Syria and had unwittingly opened the door to a suicide bombing that killed at least 32 people in a Turkish town near the Syrian border this week.

The White House said Obama had condemned Monday's bombing in the Turkish town of Suruç.

"He conveyed condolences on behalf of the American people to the families of the victims, and the two leaders affirmed that the United States and Turkey stand united in the fight against terrorism," the statement said.

(Reporting by Sandra Maler; Editing by Eric Beech and Mohammad Zargham)