U.S. President Barack Obama and Turkish President Tayyip Erdogan agreed to work together to stem the flow of foreign fighters crossing Turkey's border to join the Islamic State, the White House said.

The two leaders in a July 22 telephone call also agreed to deepen their cooperation in the fight against the IS.

Most of the thousands of foreign fighters who have travelled from Europe and the United States to join IS as it wages war in Iraq and Syria have entered through Turkish towns on the Syrian border.

Previously, Turkey was reluctant to embroil itself in the wars raging in neighboring states. But a major bombing claimed by IS in a Turkish border town July 20 that killed 32 people appears to have spurred Erdogan into taking stronger action.

The White House said Obama condemned the bombing in Suruc, as well as a second attack killing two Turkish police officers on July 22, and offered his condolences.

Based on reporting by Reuters and AP