Jihad and Peace - Muslim Rulers and the Dilemma of Alliance with the Franks

The Crusades are commonly presented as a clash of civilisations driven by the ideology of jihad on one side and holy war on the other. Yet Muslim rulers in the Latin East concluded pragmatic alliances with their Christian enemies just as readily as the Franks did. When did such arrangements serve the faith and when did they betray it?