Swat

Mahmud Ghaznavi Mosque, Udegram: Visiting Guide

Mahmud Ghaznavi Mosque at Udegram, Swat: the 1048 inscription, what the excavated ruins show, the drive from Mingora and pairing it with Raja Gira.

By Explore Pakistan · Published 25 September 2026 · 7 min read

Udegram Castle Mosque
Photo: Tan Afridi · CC BY-SA 3.0 · Wikimedia Commons

The Mahmud Ghaznavi Mosque stands on the hillside above Udegram (also spelled Odigram), about 8 km south-west of Mingora, below the ruins of Raja Gira Castle. An Arabic inscription found on the slope in 1984 dates its foundation to the Islamic year 440, which is 1048 to 1049 CE. That makes it the oldest mosque yet identified in northern Pakistan. What you visit today is an excavated ruin: high stone walls, a paved courtyard and the bases of the wooden pillars that once held the roof.

This guide covers the history and what the name gets wrong, what to look for on site, how to get there and whether it is safe to go.

At a glance
WhereHillside above Udegram village, Swat, below Raja Gira Castle
From MingoraAbout 8 km, 15 to 20 minutes by car
Founded440 AH (1048 to 1049 CE), by inscription
FounderAmir Nushtagin, a Ghaznavid general
Excavated1985 to 1999, Italian Archaeological Mission in Pakistan
SizeRectangular, 28 m by 21 m
Time needed30 to 45 minutes; half a day with the castle
EntryNo ticket price or hours confirmed; go in daylight

Weather now in Mingora, Swat 984 m

Live weather loads here.

Forecast from MET Norway (CC BY 4.0), updated every 30 minutes. Mountain weather changes fast: check again before you set off.

Who built it? The history and the name

Sultan Mahmud of Ghazni sent his armies into Swat in the early 11th century. Local tradition says his forces defeated Raja Gira, remembered as the valley's last pre-Islamic ruler, whose fortress stood on the ridge above Udegram, and that a commander named Pir Khushal died in the fighting. His simple tomb nearby is known as Ghazi Baba.

The mosque carries Mahmud's name, but he did not build it. Mahmud died in 1030. The foundation inscription, cut in Arabic on a slab of black marble, records that the mosque was ordered in 440 AH by Amir Nushtagin, a Ghaznavid general who is known from this stone and nowhere else. That date falls in the reign of Mahmud's grandson Maudud, who ruled from 1041 to 1050. Local guides tell a version in which a relative of the Sultan built it on his advice; the inscription is the firmer evidence.

The slab was found by chance in 1984. The following year the Italian Archaeological Mission in Pakistan, which has worked in Swat since the 1950s, located the building itself and excavated it in seasons up to 1999. Before the Mahmud name stuck, the ruin was known simply as the Raja Gira mosque.

What to look for on site

The mosque is a hypostyle hall, the early plan in which a flat timber roof rests on rows of columns. There was never a dome.

  • The walls. Built of local schist in the rough diaper masonry also used on Swat's Buddhist monuments. They still stand high around the hall.
  • The pillar bases. The roof and its wooden columns are gone, but the stone bases remain in the prayer hall, in rows of five one way and eight the other.
  • The mihrab. A niche in the centre of the western wall, facing Mecca. It is square in plan, which scholars treat as an early, pre-Seljuk feature.
  • The courtyard. Paved in schist slabs, with an ablution tank in the middle. The prayer hall floor sits one step higher and was beaten earth.
  • The entrance. On the east wall, set slightly off centre, facing the mihrab across the court.
  • The north side. Three long rooms and three bastion-like towers, which the excavators compare to a ribat, a fortified religious post.

Around the mosque the excavators found a graveyard, rooms thought to have housed students, and a water mill, so this was a small religious settlement and not a lone building. They also found that it was raised on an older terrace with Gandharan masonry and traces of a Buddhist stupa beneath. In one spot you are looking at roughly a thousand years of Swat's history: Buddhist, Hindu Shahi and early Islamic.

Italian-led conservation work under a Pakistan and Italy debt-swap programme has since conserved the ruin. There is no roof over the prayer hall, and the site is kept as a monument, not as a working neighbourhood mosque.

How to get there

Udegram is on the main N-95 road between Barikot and Mingora, the road almost everyone uses to enter Swat.

  • From Mingora: about 8 km towards Barikot. A taxi or rickshaw is the simple option; agree a return fare with waiting time, since there is no stand at the site.
  • From Islamabad or Peshawar: take the Swat Motorway to Chakdara, then the N-95 through Barikot. Udegram is about 11 km beyond Barikot, before you reach Mingora. Our Islamabad to Swat road guide covers the drive.
  • The last stretch: a side road climbs from the main road through the village towards the hill. Dawn reported in 2014 that the government had built an access road to the mosque. Expect a short uphill walk at the end.

We could not confirm an entry fee or official opening hours. Local guides work at the site; if you use one, agree the amount first.

Combining it with Raja Gira and other sites

The obvious pairing is the fortress above. The path to Raja Gira Castle starts from the same hillside and is a much steeper climb, so do the mosque first and decide then whether you have the legs and the time.

Udegram itself is usually identified with Ora, a town Alexander's army besieged in 327 to 326 BC, and Barikot down the road with Bazira. With a car you can make a half-day loop of it:

  1. Udegram: the mosque, then the castle if you are fit.
  2. Shingardar Stupa, beside the road towards Barikot.
  3. Barikot, for the excavated town of Bazira.
  4. Back to Mingora for the Swat Museum in Saidu Sharif, which holds finds from all of these.

Our overview of Buddhist sites in Swat covers the rest.

When to go and what to bring

The site is open hillside with little shade. From May to September go before 10 am or after 4 pm; the cooler months are more comfortable. Stone paving is slippery after rain.

Wear shoes with grip, carry water, and dress modestly as you would for any mosque. Do not count on shops or toilets at the site; use the ones in Udegram bazaar or Mingora.

Is it safe to visit Udegram?

Udegram is a settled village close to Mingora, and Pakistani visitors come here regularly. Security in Swat did worsen in 2026: a suicide bombing at Kabal police station on 2 August killed 17 people. The UK government's travel advice (updated 22 September 2026) advises against all travel to Swat district.

Check local news and police advice before you set out. Holders of foreign passports should read their own government's advice first, because travelling against it can void insurance. Our guide on whether Swat is safe for tourists has the fuller picture.

Is it worth visiting?

Yes, if early Islamic history or archaeology interests you. No other building in the north shows this period so clearly, and the setting above the valley is fine.

If you only want scenery, or have children who will tire of ruins, give it twenty minutes on the way to the castle or skip it for the Swat valley's greener stops further north.

Frequently asked questions

How old is the Mahmud Ghaznavi Mosque in Udegram?

Its foundation inscription gives the Islamic year 440, which is 1048 to 1049 CE. It is the oldest mosque identified so far in northern Pakistan.

Did Mahmud of Ghazni build the mosque?

No. He died in 1030. The inscription names a Ghaznavid general, Amir Nushtagin, as the founder, during the reign of Mahmud's grandson Maudud.

How far is Udegram from Mingora?

About 8 km towards Barikot on the main N-95 road, 15 to 20 minutes by car or rickshaw.

Is there an entry fee?

We could not confirm one, and no opening hours are published. Visit in daylight and carry small cash in case a ticket or guide fee is asked for.

Can I pray at the mosque?

It is kept as an archaeological monument with no roof over the prayer hall, not as a working mosque. For congregational prayers use a mosque in Udegram village.

How far is the mosque from Raja Gira Castle?

They share the same hillside. The mosque is a short walk from the road end; the castle is a steep climb above it.

Keep reading

More from Swat

All Khyber Pakhtunkhwa guides
Saidgai Lake

Swat

Saidgai Lake Swat: Route and Trek

Saidgai Lake sits at about 3,500 m between Swat and Upper Dir. Here are the known trails, rough trek times, the season, what to carry and the security advice.

6 min read

Timeless beauty · Serene waters · Living culture

Want us to plan it for you?

Tell us your dates, your group and where you want to go. A travel expert will shape a route for you within a day.