Construction of the mosque started in 1889, following the order of Tengku Sultan Abdul Aziz, late 19th-century ruler of the Langkat Sultanate and son of Tengku Sultan Haji Musa al-Khalidy al-Muazhzham Syah. The mosque was designed by a German architect. Many of the construction workers were the Chinese inhabitant of Langkat Regency. Material for construction were shipped from
Penang and
Singapore via the river Batang Serangan, and was transferred on site with 80 ox-carts. Abdul Aziz died before the completion of the mosque, so the construction was taken over by his son Tengku Sultan Mahmud Rahmat Syah. The mosque was completed on June 13, 1902. A minaret was added in 1926. The mosque was restored several times in 1978-1979, 1980–1981, and 1990-1991. == Architecture ==