A series of protective trenches (hadivory) and stone walls, typical of fortified royal cities in Imerina since the 15th century, surround the village of Ambohimanga.
The trenches vary in depth to a maximum of 30 meters (98 ft).
The oldest trenches at the site, called Mazavatokana, are located behind the modern-day rova and appear to predate the reign of the hill's first known king, Andriantsimitoviaminiandriana; local tradition maintains that they were dug in the early 16th century on the command of King Andrianjaka, who may have used the site as a launching point for military offensives in his war against the Vazimba.
Andriantsimitoviaminiandriana was the first to systematically establish a network of defenses around the hilltop settlement.
This first king of Ambohimanga dug trenches around his Bevato compound, which was initially only accessible through a gateway he named Ambavahadikely.

The settlement was expanded by the construction of trenches bordering a second adjoining space to the northeast with two additional access points named Ampanidinamporona and Ambavahaditsiombiomby, the latter a natural gateway formed by two boulders.
This latter entrance was most likely used to access the space even before the formal establishment of a royal city there, and is therefore considered by archaeologists to be the oldest gateway at the site.
After the establishment of the rova, this entrance was reserved for use by the sovereign, a reflection of the spiritual significance of the northeastern direction and its association with the ancestors, whose benediction and hasina provided the basis for the sovereign's power and legitimacy.
It was also used to bring sacrificial cattle into the compound.
Andriantsimitoviaminiandriana then expanded toward the west to a series of natural defenses, including stony cliffs and steep forested slopes that obviated the need to dig defensive trenches, and he constructed several additional gates that he named Ambavahadimahazaza, Andranomboahangy and Ambavahadiantandranomasina.
Andrianampoinimerina expanded the trenches around the city using fanampoana labor.
During his reign, a trench was dug that entirely encircles the hill, and a series of trenches was dug alongside existing ones to further protect the city against enemies.
The current defensive wall was reconstructed around 1830 during the reign of Queen Ranavalona I. An estimated sixteen million egg whites were mixed with lime to produce the whitewash for the compound's exterior and interior walls.
Until French colonization in 1897 and at least as early as the reign of Radama I, foreigners and non-residents were not allowed to enter the royal city without authorization from the sovereign.

The royal compound can be accessed through fourteen stone gateways in total.
In addition to the inner seven gateways constructed by Andriantsimitoviaminiandriana in the early 18th century, there exists an exterior wall and second set of seven gates that were built before 1794 during the reign of Andrianampoinimerina, an act that symbolically marked the completion of the king's reunification of Imerina.
The largest and principal gate is also the most well-preserved and is known as Ambatomitsangana ("standing stone").
 Every morning and evening, a team of twenty soldiers would work together to roll into place an enormous stone disk, 4.5 meters in diameter and 30 cm thick, weighing about 12 tons, to open or seal off the doorway.
This form of gate (vavahady in the Malagasy language), typical of most walled royal villages of Imerina built between 1525 and 1897, protected the villagers from marauders.
The gateway is topped by an observation post.
The second main entrance, called Andakana, is situated in the western wall.
Its stone disk is also intact, and the path leading to it is paved with cut stones.
Both Ambatomitsangana and Andakana were considered the gateways of the living; cadavers could not be transported through them, and passage was denied to anyone who had recently come into contact with the dead.
 A northern gateway called Miandrivahiny retains its well-
A series of protective trenches (hadivory) and stone walls, typical of fortified royal cities in Imerina since the 15th century, surround the village of Ambohimanga. The trenches vary in depth to a maximum of 30 meters (98 ft). The oldest trenches at the site, called Mazavatokana, are located behind the modern-day rova and appear to predate the reign of the hill's first known king, Andriantsimitoviaminiandriana; local tradition maintains that they were dug in the early 16th century on the command of King Andrianjaka, who may have used the site as a launching point for military offensives in his war against the Vazimba. Andriantsimitoviaminiandriana was the first to systematically establish a network of defenses around the hilltop settlement. This first king of Ambohimanga dug trenches around his Bevato compound, which was initially only accessible through a gateway he named Ambavahadikely.
The settlement was expanded by the construction of trenches bordering a second adjoining space to the northeast with two additional access points named Ampanidinamporona and Ambavahaditsiombiomby, the latter a natural gateway formed by two boulders. This latter entrance was most likely used to access the space even before the formal establishment of a royal city there, and is therefore considered by archaeologists to be the oldest gateway at the site. After the establishment of the rova, this entrance was reserved for use by the sovereign, a reflection of the spiritual significance of the northeastern direction and its association with the ancestors, whose benediction and hasina provided the basis for the sovereign's power and legitimacy. It was also used to bring sacrificial cattle into the compound. Andriantsimitoviaminiandriana then expanded toward the west to a series of natural defenses, including stony cliffs and steep forested slopes that obviated the need to dig defensive trenches, and he constructed several additional gates that he named Ambavahadimahazaza, Andranomboahangy and Ambavahadiantandranomasina. Andrianampoinimerina expanded the trenches around the city using fanampoana labor. During his reign, a trench was dug that entirely encircles the hill, and a series of trenches was dug alongside existing ones to further protect the city against enemies. The current defensive wall was reconstructed around 1830 during the reign of Queen Ranavalona I. An estimated sixteen million egg whites were mixed with lime to produce the whitewash for the compound's exterior and interior walls. Until French colonization in 1897 and at least as early as the reign of Radama I, foreigners and non-residents were not allowed to enter the royal city without authorization from the sovereign.
The royal compound can be accessed through fourteen stone gateways in total. In addition to the inner seven gateways constructed by Andriantsimitoviaminiandriana in the early 18th century, there exists an exterior wall and second set of seven gates that were built before 1794 during the reign of Andrianampoinimerina, an act that symbolically marked the completion of the king's reunification of Imerina. The largest and principal gate is also the most well-preserved and is known as Ambatomitsangana ("standing stone").  Every morning and evening, a team of twenty soldiers would work together to roll into place an enormous stone disk, 4.5 meters in diameter and 30 cm thick, weighing about 12 tons, to open or seal off the doorway. This form of gate (vavahady in the Malagasy language), typical of most walled royal villages of Imerina built between 1525 and 1897, protected the villagers from marauders.The gateway is topped by an observation post. The second main entrance, called Andakana, is situated in the western wall. Its stone disk is also intact, and the path leading to it is paved with cut stones. Both Ambatomitsangana and Andakana were considered the gateways of the living; cadavers could not be transported through them, and passage was denied to anyone who had recently come into contact with the dead.  A northern gateway called Miandrivahiny retains its well-
Ambohimanga