In 1529, Alauddin Riayat founded his first capital in Hujung Tanah, known as Pekan Tua, 11 km upriver from Kota Tinggi, following the death of his father. A river fort, Kota Kara was also founded down the river. In 1535, about 400 Portuguese troops led by Estêvão da Gama invaded Johor. Kota Kara was bombarded but the Malays withstood the attack. After a few days, Portuguese troops landed and bombarded the fort but they also had to retreat. Their morale boosted by this initial success, the Malays left their fort and launched a counter-attack on the Portuguese. However, the Malays were scattered by the crossfire of the Portuguese which resulted in the capturing of the fort and its burning by the Portuguese. Alauddin Riayat retreated upstream the Johor River to Sayong Pinang. His official, Seri Nara Diraja, died in Sayong Pinang. Alauddin Riayat returned to Pekan Tua after a short period and rebuilt it. Pekan Tua was attacked by 400 Portuguese troops under Estêvão da Gama again because his brother, Paulo da Gama, and about 30 other Portuguese troops were killed by Malays. Following this attack, a peace treaty was signed between Johor and the Portuguese. In 1540, Alauddin Riayat Shah moved his capital to Johor Lama, which is closer to the estuary of Johor River.
Acehnese threats
Johor was also threatened by Aceh, on the northern tip of Sumatra. In 1539, Aru, Johor's vassal state on the east coast of Sumatra, was attacked by a fleet of 160 ships with 12,000 soldiers, being Acehnese, Malaccan Malays, Malabaris, Gujaratis, and Turkish. Alauddin Riayat gathered a fleet with aid from his allies, Perak and Siak, and attacked Aru in 1540. He reconquered Aru, leaving only 14 Acehnese ships afloat and thousands of Acehnese troops dead. The battle was called, Battle of Sungai Paneh, which was the most glorious Malay victory since they were defeated in Malacca. In 1564, the Sultan of Aceh, Alauddin al-Qahar, defeated Aru and expulsed the Johoreans from Aru. The sultan of Aceh, then, launched an attack on Johor Lama from Aru. The fort and town was leveled and Alauddin Riayat was captured and brought back to Aceh. He was later killed and was given the posthumous title, Marhum Syahid di Acheh. He was succeeded by his son, Muzaffar Shah II.