To hear them talk about each other in recent years, you’d think the relationship between the United States and the Muslim world had been permanently belligerent. The violence and inflammatory polemics generated by the 9/11 terrorist attacks and the wars in Iraq and Afghanistan make it difficult to think otherwise. But if intellectual history is any guide, there was a time when no Western nation was as positively engaged with Islamic civilization as the United States.

A few examples clarify the history of relations between the United States and Islam. A Muslim country, the kingdom of Morocco, was the first to recognize the independence of the United States, as President Obama recently noted in his Cairo address. In 1778, George Washington and Sultan Mohammed III of Morocco signed a treaty of friendship protecting all vessels carrying the “American flag” from piracy.

Judging from poems, plays, and novels written during the early years of the American republic, this first encounter with a Muslim-majority nation set the tone for 18th- and 19th-century Americans to gradually begin an intense cultural dialogue with Muslims and Arabs.

Royall Tyler’s Algerine Captive, considered the second-oldest American novel, is a prime example. Written in 1779, Algerine Captive is about a doctor from Boston who is captured by Muslim Barbary pirates and then sold into slavery in Algeria. The main character, Dr. Updike Underhill, spends several years in captivity before gaining his freedom and returning to America.

Out of print for more than two centuries, the novel has been revived, with an unfortunate irony: It was reprinted in 2002 to provide historical background for the 9/11 tragedy. As one critic wrote on its cover, the novel “lays bare a culture clash and diplomatic quagmire not unlike the one that obtains between the United States and Muslim nations today.”

True, the novel’s tense atmosphere allows such a comparison, especially if one equates 18th-century piracy to modern terrorism. On closer inspection, however, the novel can serve as a reference to counter, not support, the clash-of-civilizations rhetoric; the narrative dramatizes political conflict with Islam only in order to imagine ways to resolve it.

Tyler transformed the politics of captivity into a fascinating quest for knowledge. His protagonist initiates multiple dialogues about controversial issues – such as American slavery, stereotyping, and religious conversion – with his Algerian captors, imams, and others, eager at once to discover Islamic culture and to promote his own Christian faith.

Royall Tyler paved the way for more famous writers – the pioneers of the American Renaissance – to expand their society’s knowledge of Islamic culture. Washington Irving wrote a book about the Prophet Muhammad; Edgar Allan Poe crafted an intriguing story about the Arabian Nights; and Herman Melville drew extensively on Arabic texts in his classic Moby-Dick, whose main characters include the Arabic-named Ishmael, his companion the Ramadan-fasting Queequeg, and the Persian Fedallah.

By 1850, the Arabian Nights was so popular in the American imagination that Harriet Beecher Stowe, another major figure of the American Renaissance, exhorted American parents to tell Scheherazade’s stories to their children in order to cultivate their aesthetic values and appreciation for difference.

References to the Quran, the prophet Muhammad, and his companions were common practice among the Founding Fathers, writers, and poets, from Benjamin Franklin and Thomas Jefferson to Ralph Waldo Emerson and Walt Whitman. Emerson, the father of American transcendentalism, described the Quran as the “kingdom of the will,” encouraging his American readers to view the prophet [and his companions] “Mahomet, Ali, and Omar” as inspiring models of balanced “vigor” nurtured by “the sound mind in a sound body.”

Although transcendentalism has been marketed as an American cultural brand, Emerson acknowledged that it was an Eastern, Sufi (or mystical Islamic) philosophy, originally inspired by Persian poets he read and translated.

All this is worth keeping in mind as Americans and Muslims are about to open a new chapter in their relationship. To understand that our past traditions were much more tolerant of mutual differences than we tend to think will help us liberate the dialogue from the terrorists acting in the name of Islam and the conservative ideologues waiting for the latter’s bombs to set off their own clash of civilizations. The challenge is certainly worth the effort of all Americans who believe in the richness of their own legacy.

Mokhtar Ghambou is a professor of post-colonial studies and American literature at Yale University and president of the American Moroccan Institute.