VARANASI, INDIA -- The legend of the Gyan Wapi mosque, a 17th-century structure nestled in a congested square near the Ganges River, may explain as well as anything else why Hindus and Moslems are willing to fight and die over their places of worship.

The mosque's history, as told by Hindus who want to see it torn down or at least removed, is an epic tale of religious wars, heroic priests, evil generals, mass slaughter, a princess who had a dream that she should build a temple and a Brahmin who saved a jeweled idol from Moslem invaders by diving down the well of knowledge.

A full account would require several volumes, but for a taste of the story consider the arrival at the banks of the Ganges in 1669 of general Black Mountain, emissary of northern India's 17th-century Moslem ruler Aurengzeb. So named because he was tall, dark-skinned and rode a black horse, Black Mountain brought with him several cannon and orders from Aurengzeb to smash a Hindu temple believed to be a seat of "wicked sciences," according to Hindu historians.

As battles raged and Black Mountain's forces neared the temple, which had been erected to the Hindu god Shiva, the temple's priest grabbed an emerald idol shaped like a phallus and hurled himself down a well. His body was recovered, but the emerald supposedly slipped into an estuary and disappeared into the Ganges. Triumphant but frustrated, Black Mountain smashed the temple and built the mosque that stands today.

On the back wall of the mosque are visible what appear to be the ruins of a Hindu temple, which Hindu activists say were left standing by Aurengzeb's deputies to humiliate Varanasi's conquered Hindu population. Hindus believe that under the square lie buried thousands of soldiers and generals who died in the battle.

In 1937, a British-appointed magistrate asked to calm Hindu-Moslem fighting over the mosque examined evidence and more or less accepted this version of history, although in an apparent effort to be balanced, he wrote in his judgment that if Aurengzeb really believed wicked sciences were being practiced at the temple, then he was justified in ordering Black Mountain to tear it down.

Today, the mosque is number two on a list of Moslem religious sites that Hindus want removed so that Hindu temples can be rebuilt. Number one is the disputed Babri Masjid in Ayodhya, where the historical evidence is much scantier.

"These mosques were built in the process of empire building to demoralize the Hindu population and to convince them that their gods were not as powerful as Islam," said Suresh Awasthi, a Varanasi University lecturer and local Hindu leader.

But Moslems are fighting back. "If you want revenge, it should be against a person, not against history," said Naseer Benarsi, an 85-year-old Moslem poet. "I can say that if I had lived in Aurengzeb's time, I would have resisted {his armies}. But since I was not alive at the time, why rain on me?"