Raja Ali Haji was born in Selangor (although some sources stated that he was born in Penyengat)[2] in 1808 or 1809,[3] and was the son of Raja Ahmad, who was titled Engku Haji Tua after accomplishing the pilgrimage to Mecca. He was the grandson of Raja Ali Haji Fisabilillah (the brother of Raja Lumu, the first Sultan of Selangor).[4] Fisabilillah was a scion of the royal house of Riau, who were descended from Bugis warriors who came to the region in the 18th century.[5] His mother, Encik Hamidah binti Malik was a cousin of her father and also of Bugis descent.[6] Raji Ali Haji soon relocated to Penyengat as an infant, where he grew up and received his education there.[7]