The fort was built in the 1870s as the private residence of Ngah Ibrahim, a Malay statesman in Perak. After the murder of J.W.W. Birch, the first British Resident in Perakat Pasir Salak on 1 November 1875, the fort became a court for the trial of Birch's murder.
Dato Maharajalela, Dato' Sagor, Sepuntum and Pandak Indut were found guilty and were sentenced to death by hanging at the court on 21 January 1877. Ngah Ibrahim, Sultan Abdullah and other statesmen were exiled to Seychelles in the Indian Ocean. Ngah Ibrahim died on 1887 in Singapore and was buried at the Masjid Al-Junied cemetery. However, on 7 September 2006, Ngah Ibrahim's body was brought back to Perak and reburied near his house.
In the 1900s, the court was moved to a new building at Taiping. In 1913, the house was turned into the first Teachers' Training College for Malay teachers, known as the Matang College. Ten years later on 1923, the college was closed for the new Sultan Idris Training College in Tanjung Malim. Subsequently, the residence was turned into a primary school, Sekolah Rendah Kebangsaan Matang.
During the Japanese occupation in 1941, the Japanese Imperial Army made the fort its headquarters and war strategic operations centre. After the Japanese surrendered in 1945, the fort was turned again into Sekolah Rendah Kebangsaan Matang until 1982 when the school was moved to the new building near the fort. From 1987, this fort was taken over by the Perak Museum Department as a state historical site known as Kota Ngah Ibrahim Historical Complex.
Other attractions nearby Kota Ngah Ibrahim