ISTANBUL—President Recep Tayyip Erdogan of Turkey stepped up his attacks on the U.S. on Tuesday, calling for a boycott of Apple Inc.’s iPhones and other U.S. electronic goods, while his foreign minister joined his Russian counterpart in criticizing Western sanctions.

Turkey, a longtime North Atlantic Treaty Organization ally, has been caught between the West and Russia. This week, officials in Ankara were leaning decidedly toward Moscow.

In...