In a vastly over simplification of history, Thomas Jefferson was the first American president to fight war on Muslim nations. The Marine Corps were actually created to do the job.
The reason for the war was the Muslim enslavement and ransom of Americans. In fact ten percent or more of the national budget was used for paying such ransom to the Muslim pirates. The four Barbary nations were engaged in slavery and ransom of Americans, and Europeans. Enslavement of Americans was not to be taken lightly.
The envoys of the Barbary nations declared “It was written in the Koran, that all Nations who should not have acknowledged their authority were sinners, that it was their right and duty to make war upon whoever they could find and to make Slaves of all they could take as prisoners, and that every Mussulman who should be slain in battle was sure to go to Paradise.”. The first American response was theTreaty of Tripoli, which in 1797 had attempted to formalize the dues that America would pay for access to the Mediterranean, stated in its preamble that the United States had no quarrel with the Muslim religion and was in no sense a Christian country.
That did not work. Increasing demands from the Barbary nations eventually caused Jefferson to refuse to to pay tribute. The Barbary nations promptly declared war. America more or less succeeded in what is called the 1st Barbary war. In doing so we successfully opened up trade routes in the Mediterranean.