Article snapshot taken from Wikipedia with creative commons attribution-sharealike license.
Give it a read and then ask your questions in the chat.
We can research this topic together.
The gate originally dates back to around 1126 when the Almoravid ruler Ali ibn Yusuf built the first walls of the city, but it has been modified since this time. It was named after Aghmat, the early capital of the Almoravids before Marrakesh, which lay in this direction (i.e. to the south/southeast). The gate may have also been called Bab Yintan, though this is uncertain and this name may have referred to another nearby gate which has since disappeared.
Like other Almoravid gates of the city, it has been significantly modified since its initial construction. Originally, it most likely consisted of a bent passage which effected a full 180-degree turn, forming a symmetrical structure around the axis of the wall: one entered from the west through a bastion on the outer side of the city wall, passing through a roofed vestibule, then exited westwards from the bastion on the inner side of the wall, passing through an open-air court. In a much later period a walled courtyard with a very different construction style was added on the outer end of the gate, forcing traffic to effect one more 180-degree turn (though in recent times the northern wall of this courtyard has been knocked down to allow a more direct passage). A staircase in the northeastern corner of the gatehouse leads to the roof.