The official national history claims that Brunei can trace its beginnings to the 7th century, when it was a subject state named P'o-li, in the Sumatra-centric Srivijayan empire. It later became a vassal state of the Java-centric Majapahit empire. Brunei became a sultanate in the 14th century, under a newly converted Islamic sultan—Muhammad Shah.
At the peak of Bruneian Empire, Sultan Bolkiah (reigned 1485–1528) had control over the northern regions of Borneo, including modern-day Sarawak and Sabah, as well as the Sulu archipelago off the northeast tip of Borneo, Seludong (modern-day Manila), and the islands off the northwest tip of Borneo. The maritime state was visited by Spain's Magellan Expedition in 1521 and fought against Spain in 1578's Castille War.