He served as the third Kapitan China of Kuala Lumpur, and in this administrative capacity, played an important role in developing the city as a commercial and mining centre during the 19th century.
His parents lived in the town of Danshui/Tamsui (Chinese: 淡水; pinyin: Dànshuǐ) in Kwai Yap district, Huizhou prefecture.
Instead of going back to Malacca, he and another of his relatives named Yap Fook travelled on foot to Lukut, then still part of Selangor (now Port Dickson, Negeri Sembilan).
[3] There were also constant warfare between two Chinese gangs, the Hakka-dominated Hai San (dominant in Kuala Lumpur) and the Cantonese-dominated Ghee Hin (based mainly in the Kanching and Rawang area), who fought to gain control of tin production in the town.
[9] Yap's victory at Kuala Lumpur in 1873 placed him in a strong political position, and he was almost supreme in the interior of the state.
[10] Yap's achievement in the postwar recovery of the mining industry established Kuala Lumpur as the economic centre of the peninsula.
As the acknowledged leader of the Chinese community, he was given the powers similar to a Malay ruling chief by the British, except for the right to tax, a restriction he easily evaded.
In 1879, the first British resident (government advisor) was assigned to Kuala Lumpur, and from that time the power of the Kapitan began to be undermined.
On 1 September that year, a violent storm struck the Klang Valley, causing widespread damage to property in Kuala Lumpur.
[11] During the early times, Kuala Lumpur was beset with many problems, including the Selangor Civil War which devastated the town.
[14] Hence, Kapitan Yap Ah Loy bought a sprawling piece of real estate for the setting up of a brick industry which would spur the rebuilding of Kuala Lumpur.
Many of the new brick buildings mirrored those of shop houses in southern China, characterized by "five foot ways" as well as skilled Chinese carpentry work.
Kapitan Yap Ah Loy also built Kuala Lumpur's first school and a major tapioca mill in Petaling Street in which the Selangor's Sultan Abdul Samad had an interest.
In 1896, Kuala Lumpur was chosen as the capital of the newly formed Federated Malay States due to its central position.
The doctor examined Yap's body and later confirmed that his death was either due to heart failure or poisoning by the fumes of the charcoal brazier.