The original building is believed to be founded here in 627 by Abu Waqas, an uncle of the prophet Mohammed. The present mosque dates from the Qing dynasty.