If you want to be overwhelmed by the sight and fragrance of vast fields of citrus, the Agdal Gardens of Marrakech are as good a place as any. These ancient orchards, almost 900 years old, lie to the south of the Dar el Makhzen (the Royal Palace), about a 45-minute walk along hot dusty paths from the frantic chaos of the city’s central square, the Jamaa el Fna.

The original gardens – the name is derived from the Berber for “walled meadow” – were planted in the 12th century by Abd al-Mu’min, the first Caliph of the Almohad dynasty. Al-Mu’min had recently led the Almohads to victory over the ruling Almoravids, and the capture of Marrakech was the prize – drenched in the blood of 7,000 dead. After so much slaughter he was probably ready for a bit of gardening and at Agdal he did so; on a grand scale. Renovated 400 years later during the Saadi dynasty, the gardens were further enlarged in the 19th century by Sultan Moulay Abd al-Rahman. It was during this final stage of expansion – to the present, vast, 400 hectares – that the site was hemmed in with imposing pisé walls with crenellated buttresses that also served as defensive walls for the city. These thick walls were made using a technique well known through the ancient world, by mixing and ramming earth and aggregates together in layers, then leaving to air-dry to an almost concrete-like consistency.

Today the Agdal are still royal gardens, only open to the public on Fridays and Sundays and not at all if the king is in residence. They comprise a series of large orchard groves of lemon, orange, fig, pomegranate and apricot in rectangular plots. Ease of harvesting and maintenance is uppermost in this design but the result of such huge numbers of single species planted together in flower and fruit is awe-inspiring.

Orange and clementine orchards in the Agdal Gardens

Dirt tracks and walkways connect the plots, which are lined with olive trees and punctuated by groves of tall palms. If you expect polished perfection, you’ll be disappointed. This is a working orchard, not an ornamental garden, complete with the associated detritus and paraphernalia. There is the occasional plastic sack, old bicycle and broken-down moped among the fruit trees, and the gardeners – who putter around on creaking tractors and mule-hauled wagons – deploy canisters of ominous-looking liquid to keep pests and diseases at bay.

But, if you can see past those minor distractions, the Agdal is undeniably and memorably beautiful. There is an extraordinary stillness to the place, in sharp contrast to the hustle and bustle of the centre of Marrakech and the constant hum of the souk, Medina and Jamaa el Fna. And when the citrus trees are in flower – in early spring for most of the orange varieties, three or four times a year for the lemons – the air is laden with fragrance to an extent that few other gardens can match.

The success of the citrus orchards is due to three factors. Marrakech is reliably warm: 6C is the average December low rising to a 48C high in August, with excellent light levels and plenty of sunshine, and Agdal’s south-facing orientation maximises its exposure to the sun. The pisé walls and densely planted orchards create a sheltered environment that protects the blooms and young fruit. But without water, the Agdal gardens would have failed centuries ago.

City walls border the Agdal Gardens

Rain and meltwater from the High Atlas mountains, which rise 20km or so away to the southeast, is fed into the gardens. This ancient irrigation system uses a network of ditches and channels (khettera) to deliver the water.

Following the route of the khettera upstream into the High Atlas reveals the beautiful simplicity of the system. Here on the mountainsides the growing is done over a network of small terraces. Each terrace is planted with a small number of fruit or nut-bearing trees, sweet fodder grasses and edged with bearded iris rhizomes, the flowers and roots of which are sold as a cash crop. Djellaba-clad villagers carry out irrigation duties collectively, banking up or knocking down earth berms to divert water on to pathways that become temporary streams and in turn discharge into one terrace network or another.

At Agdal the water from the High Atlas is stored in a number of pools, the largest of which is the Sahraj el-Hana (Tank of Health). This is a massive formal water feature: a square, stone-edged pool filled with silt-laden water populated by hungry carp that can sense the arrival of a bread-bearing tourist from a considerable distance. The pool is overlooked by an understated, compact pavilion, the Dar El Hana.

The Sahraj el-Hana or ‘Tank of Health’ pool stores rain and meltwater from the High Atlas mountains

From the Sahraj el-Hana and the various other storage pools, the water radiates out into the gardens via a network of earth ditches. It’s then further diverted into specific orchard areas using the same technique employed by the villagers in the High Atlas; banking up and knocking down berms formed from the orange-brown earth to channel the water in each direction.

Orange blossom flowers in spring

The result of this ready supply of water can be seen on the ground in the health of the trees and the bounty of the fruit, but is most striking when seen in a satellite image. The Agdal appears as a huge, dark green rectangle projecting south into the dry, straw-coloured landscape beyond.

It’s also a stark reminder of the importance and fragility of this ancient system. Increased demands for water in Marrakech – for golf courses, swimming pools and for expanding production of crops such as tomatoes and peppers for export – risk permanent damage to the Agdal Gardens, and the traditional methods of subsistence farming in the High Atlas. The significance of this magical place was recognised in 1985, when Unesco listed Agdal, the Medina and the Menara Gardens as a World Heritage Site.

Where to see citrus

Versailles Hundreds of citrus trees grown in the eponymous Caisse Versailles is one of the highlights of these famous gardens.

Los Olivos, California The orange groves here may play second fiddle to the more celebrated vineyards but their fruit, frequently sold from roadside stands, is the best I’ve tasted.

Château de Villandry, Loire The Renaissance potager, one of the most extensive created, features pot-grown and wall-trained citrus.

Sóller, Majorca Take the ancient wood-panelled train from Palma and the memory of the approach to Sóller, through lemon and orange groves, will stay with you forever.

Vizcaya Gardens, Miami Created in 1916 by industrialist James Deering there are 10 acres of formal, Renaissance-inspired gardens.

A potted orange tree

● Citrus need a bright sunny position year-round.

● Spring planting is best for ground-planted citrus.

● In cool climates they’re best grown in pots, which can be moved outside into a sheltered, sunny spot once temperatures are stable, with no risk of frost.

● Sudden changes in temperature can cause flowers and young fruit to drop. Potted plants left near frequently opened doors are prone to failure for exactly this reason.

● Soil-based compost (such as John Innes No 3) is ideal for pot-grown plants, mixed with about 20 per cent sharp grit. Citrus like well-drained soil in the ground, so heavier soils should be improved by digging in sharp grit in the base of the planting pit (to around 10cm) and in the backfill.

● Citrus are nutrient-hungry plants that benefit from high nitrogen summer feeds and an annual feed (mid-spring) of potash with a mulch of organic matter – compost or rotted manure – when planted in the ground. There are specially formulated feeds for pot-grown plants. Stop feeding from autumn to early spring.

● Water regularly throughout summer, if possible with rainwater. Erratic watering can cause fruits to wrinkle and drop.

● Citrus dislike the dry atmosphere created by central heating. If you keep your citrus indoors, place a large tray under the pot and fill it with gravel. Top up the tray with water regularly, mist the leaves and allow good ventilation to reduce the risk of fungal diseases.

● Misting also helps pollination.

● No regular pruning is required, only formative pruning.

● In general, outdoor edible citrus need frost-free (zone 8 and above) growing conditions. In autumn bring potted citrus indoors into a frost-free conservatory, glasshouse or orangery. Meyer lemons can tolerate winter temperatures to 5C, species Citrus limon to around 10C. Grapefruit are hardier and can even take an occasional frost, but are better given protection. The Japanese bitter orange and yuzu are both hardy to below -10C, but both are inedible.