"God cannot be used for personal interests and selfish ends; he cannot be used to justify any form of fundamentalism, imperialism or colonialism," the pope said in an address to Muslims, Christians, Jews and members of other faiths at the mosque, Reuters reported.
Francis has made similar appeals before and also has visited mosques on his world travels.
But his visit to Azerbaijan, whose population of about 9 million people are mostly Shia Muslims, was the first time he had made such an appeal from inside the main prayer hall of a mosque in the presence of representatives of other religions.
The pontiff's first stop after he arrived in Azerbaijan's capital, Baku, on Sunday morning was a modern church where he said a Mass for the miniscule Catholic community.