People were fishing here long before anyone wrote the place down. At Ras al-Hamra, burials of fishermen go back to the 6th millennium BC, and Harappan pottery found south of the city shows early contact with the Indus Valley. By the 1st century AD the Greek geographer Ptolemy knew the harbour as Cryptus Portus, the Hidden Port.
Sassanid Persians took the port in the 3rd century, and Islam arrived in the 7th. In the 9th century the first Imamate began pulling Oman's tribes together into an Ibadi state, and Ibadi Islam is still the faith of most Muscatis. The coast grew rich on sea trade and close ties with India, while the interior felt left behind.
In 1507 the Portuguese admiral Afonso de Albuquerque sailed in hoping to trade. Muscat's guns fired on his ships, so he took the town instead, and most of it burned. Portugal held on for more than a century despite Ottoman attacks. In the 1580s it built the forts you still see on both harbours. Jalali and Mirani face each other across the palace bay; a third overlooks Mutrah.
Omanis took their port back. Imam Nasir bin Murshid, elected in 1624, shifted the balance, and in January 1650 a small force of the Imam's men attacked at night and forced the Portuguese to surrender. Hindu merchants from Sindh and Kutch, settled in the port for generations, helped drive the Europeans out. After civil war and Persian raids in the 18th century, the Al Bu Sa'id family came to power, and they rule Oman to this day. Muscat became the capital in 1793, taking over from Rustaq.
Under Said bin Sultan in the 19th century, Muscat ruled an empire that reached East Africa. He signed a treaty with the United States in 1833, then moved his capital to Zanzibar's Stone Town in 1840. When he died in 1856, his sons split the empire: Zanzibar went one way and Oman the other. The ties left traces you can still hear, as Swahili is one of the languages spoken in Muscat.
Then came a long decline. Tribes from the interior attacked Muscat and Mutrah in 1895 and 1915, and Sultan Said bin Taimur ran a country almost closed to the outside world, eventually retreating to Salalah. The old city gates were still in use until the 1970s. On 23 July 1970 his son Qaboos removed him in a bloodless coup, renamed Muscat and Oman the Sultanate of Oman, and started building. Ghalya's Museum in Mutrah furnishes houses as they were just before that year, a good way to measure how fast things changed.
Under Qaboos came a new port at Mina Qaboos and an airport at Seeb. The village of Ruwi became a district of offices and shops. Migrants from across the region followed. Qaboos died in January 2020 and his cousin Haitham bin Tariq took the throne; the vast majority of Omanis still revere the old Sultan.