During the 17th century the Funj state reached its widest extent, but in the following century it began to decline. A coup in 1718 brought a dynastic change, while another one in 1761–1762 resulted in the Hamaj regency, where the Hamaj (a people from the Ethiopian borderlands) effectively ruled while the Funj sultans were their mere puppets. Shortly afterwards the sultanate began to fragment; by the early 19th century it was essentially restricted to the Gezira.