For the initial seven years of his government, Mr. Erdoğan built up Israeli ties, economically and other. During those times people's religions were the same as they are now. It is nothing to do with religion. Hamas is elected body of palestenians, so he supports aggrieved palestenians in their just cause.
12 Iraqi troops, militiamen killed in multiple ISIS suicide attacks (AP)
from the article: Turkey PM consoles Hezbollah leader over top Shi'ite cleric's death