the gate of a walled town or building: the controlled opening in the wall, and the public space there where the community's life was conducted
In the ancient world a city's gate was far more than a door. It was the one guarded break in the defensive wall, so whoever held the gate held the town, and it was the natural choke point through which everyone and everything passed in and out. Because all the traffic funneled through it, the gateway became the town square: a broad chamber and the open ground around it where elders sat to judge cases, where deals were struck and witnessed, where news and gossip changed hands, and where kings and prophets addressed the people. This is why one Hebrew word covers what English splits between the physical gate and the public life that happened there.
That double duty fed a natural shorthand. To speak of someone's gates came to mean their town or settlement itself, the place their authority reached, which is why the law repeatedly says to do or not do a thing within your gates. From the same root the word also reaches into poetry and prayer: the gates of a city, of the temple, even of death and of the grave, stand for the threshold between one realm and another, the point of entry that decides who gets in.
The senses below are not separate words but one idea seen from different angles: the structure, the civic and legal scene that gathered at it, the town it stood for, and the figurative thresholds it lent its name to.