In the conflict resistless, each toil they endured,This, it turns out, is the third stanza of a Francis Scott Key poem that Key ultimately reworked into the Star-Spangled Banner. Thanks to Michael Oren's fascinating Power, Faith, and Fantasy, which alerted me to this.
'Till their foes fled dismayed from the war's desolation:
And pale beamed the Crescent, its splendor obscured
By the light of the Star Spangled flag of our nation.
Where each radiant star gleamed a meteor of war,
And the turbaned heads bowed to its terrible glare,
Now, mixed with the olive, the laurel shall wave,
And form a bright wreath for the brows of the brave.
The chapter on America's war against the Barbary pirates is particularly interesting. Among other things, it reveals that Key's victory song in 1805 was premature: The 1805 victory involved a payment of $60,000 for the release of American sailors held captive by Tripoli, and was followed by continuing captures of American ships by Algerian corsairs, the enslavelement of the ships' crews, and payments by America for the crews' release.
Only in 1815, after the end of the War of 1812 with Britain, did the American navy decisively defeat the corsairs. "So concluded more than three decades of struggle between United States and North Africa. The pirates of Barbary who had captured a total of thirty-five American vessels and seven hundred sailors, and who had threatened America's survival and tarnished its pride, were crushed."
The book also notes that, though the conflict with the Barbary States was sometimes cast a Christendom/Islam conflict, and led to an exacerbation of hostility against Islam (which was already considerable, given that the late 1700s and early 1800s weren't exactly an ecumenical era), it didn't seem to have much of a long-term effect into the 1800s: America ended up having relatively good relations with the Ottoman Empire, for instance, throughout much of the 1800s, partly because it — unlike the European powers — had no territorial ambitions in the area.