In the thirteenth and the early part of the fourteenth centuries Bruni owed allegiance alternately to two powers much younger than herself, Majapahit in Java, and Malacca on the west coast of the Malay Peninsula. Both these states were founded in the thirteenth century.[13] Majapahit, originally only one of several Javan kingdoms, rapidly acquired strength and subjugated her neighbours and the nearest portions of the islands around. Malacca, formed when the Malay colony of Singapore was overwhelmed by Javanese, became the great commercial depot of the Straits and the chief centre of Mohammedanism in the Archipelago. The two powers therefore stood for two faiths and two cultures: Majapahit for Brahminism and Hindu influence, Malacca for Islam and the more practical civilisation of Arabia.

In the earliest years of the fourteenth century Bruni was a dependency of Majapahit, but seems to have recovered its independence during the minority of the Javan king. It is to this time that the tradition of the Kapuas Malays ascribes the arrival of the Kayans in Borneo.[14] Then Angka Wijaya extended the power of Majapahit over Palembang in Sumatra, Timor, Ternate, Luzon, and the coasts of Borneo. Over Banjermasin he set his natural son. In 1368 Javanese soldiers drove from Bruni the Sulu marauders who had sacked the town. A few years later the ungrateful king transferred his allegiance to China, and not long afterwards, with calculating humility, paid tribute[15] to Mansur Shah, who had succeeded to the throne of Malacca in 1374 A.D.

An extraordinary incident occurred at the beginning of the fifteenth century, which again — and for the last time — draws our attention to the Chinese court. The great Mongol conquerors, Genghis and Kublai Khan, had little to do with the Malay Archipelago, though the latter sent an unsuccessful expedition against Java in 1292. But the Ming emperors, who were of Chinese blood, came to power in 1368 and soon developed the maritime influence of the empire. For a few years there was a continual stream of East Indian embassies. During the last twenty years of the century, however, these became more rare, and in 1405 the Chinese emperor found it necessary to send a trusted eunuch, by name Cheng Ho, to visit the vassal states in the south. This man made several journeys, travelling as far as the shores of Africa, and his mission bore immediate fruit. Among others, Maraja Kali, king of Puni, although Cheng Ho does not appear to have called on him in person, sent tribute in 1405; and so pleased was he with the embroidered silk presented to him and his wife in return, that he visited the Son of Heaven three years later. Landing in Fukien, he was escorted by a eunuch to the Chinese capital amid scenes of great rejoicing. The emperor received him in audience, allowing him the honours of a noble of the first rank, and loaded him with gifts. The same year, having accomplished his one great ambition of "seeing the face of the Son of Heaven," this humbled monarch died in the imperial city, leaving his son Hiawang to succeed to the throne of Puni. Having induced the emperor to stop the yearly tribute of forty katties of camphor paid by Puni to Java, and having agreed to send tribute to China every three years, Hiawang returned home to take up the reins of government. Between 1410 and 1425 he paid tribute six times, besides revisiting the Chinese Court; but afterwards little Puni seems to have again ignored her powerful suzerain.

It is probable that the Chinese colony in North Borneo which gave its name to the lofty mountain Kina Balu (Chinese widow) and to the Kina Batangan, the chief river which flows from it, was founded about this time. Several old writers seem to refer to this event, and local traditions of the settlement still survive. The Brunis and Idaans (a people in the north not unlike the Bisayas) have legends differing in detail to the effect that the Chinese came to seize the great jewel of the Kina Balu dragon, but afterwards quarrelled about the booty and separated, some remaining behind. The Idaans consider themselves the descendants of these settlers, but that can only be true in a very limited sense. Both country and people, however, show traces of Chinese influence.

There is good evidence that the Chinese influence and immigration were not confined to Bruni and the northern end of the island. In south-west Borneo there are traces of very extensive washings of alluvial gravels for gold and diamonds. These operations were being conducted by Chinese when Europeans first came to the country; and the extent of the old workings implies that they had been continued through many centuries. Hindu-Javan influence also was not confined to the court of Bruni, for in many parts of the southern half of Borneo traces of it survive in the custom of burning the dead, in low relief carvings of bulls on stone, and in various gold ornaments of Hindu character.

The faith of Islam and the arrival of Europeans have profoundly affected the manners and politics of the East Indies, and now it is difficult to picture the state of affairs when King Hiawang revisited China to pay homage to the Emperor. In 1521, within a hundred years of that event, Pigafetta, the chronicler of Magellan's great exploit, was calling on the "Moorish" king of Bruni, in the course of the first voyage round the world. The change had come. Of the two new influences, so potent for good and evil, Mohammedanism made its appearance first. The struggle for religious supremacy ended in the complete victory of the Prophet's followers in 1478, when Majapahit was utterly destroyed, thirty years before the capture of Malacca by the Portuguese.

How early the Arab doctrines were taught in Bruni is impossible to state with any precision. Local tradition ascribes their introduction to the renowned Alak ber Tata, afterwards known as Sultan Mohammed. Like most of his subjects this warrior was a Bisaya, and in early life he was not a Mohammedan, not indeed a civilised potentate at all, to judge by conventional standards; for the chief mark of his royal dignity was an immense chawat, or loin-cloth, carried as he walked by eighty men, forty in front and forty behind. He is the earliest monarch of whom the present Brunis have any knowledge, a fact to be accounted for partly by the brilliance of his exploits, partly by the introduction about that time of Arabic writing. After much fighting he subdued the people of Igan,[16] Kalaka, Seribas, Sadong, Semarahan, and Sarawak,[17] and compelled them to pay tribute. He stopped the annual payment to Majapahit of one jar of pinang juice, a useless commodity though troublesome to collect. During his reign the Muruts were brought under Bruni rule by peaceful measures,[18] and the Chinese colony was kept in good humour by the marriage of the Bruni king's brother and successor to the daughter of one of the principal Chinamen.

Alak ber Tata is said to have gone to Johore,[19] where he was converted[20] to Islam, given[21] the daughter of Sultan Bakhei and the title of Sultan, and was confirmed in his claim to rule over Sarawak and his other conquests.[22]

Sultan Mohammed was succeeded by his brother Akhmad, son-in-law of the Chinese chief, and he was in turn succeeded by an Arab from Taif who had married his daughter. Thus the present royal house of Bruni is derived from three sources — Arab, Bisaya, and Chinese. The coronation ceremony as still maintained affords an interesting confirmation of this account. On that occasion the principal minister wears a turban and Haji outfit, the two next in rank are dressed in Chinese and Hindu fashion, while the fourth wears a chawat over his trousers to represent the Bisayas; and each of these ministers declares the Sultan to be divinely appointed. Then after the demonstration of loyalty the two gongs — one from Menangkabau, the other from Johore — are beaten, and the Moslem high priest proclaims the Sultan and preaches a sermon, declaring him to be a descendant of Sri Turi Buana, the Palembang chief who founded the early kingdom of Singapore in 1160 A.D., who reigned in that island for forty-eight years, and whose descendants became the royal family of Malacca.

The Arab Sultan who succeeded Akhmed assumed the name Berkat and ruled the country with vigour. He built a mosque and converted many of his subjects, so that from his reign Bruni may be considered a Mohammedan town. To defend the capital he sank forty junks filled with stone in the river, and thus formed the breakwater which still bars the entrance to large ships. This work rose above the water level, and in former times bristled with cannon. Sultan Berkat was succeeded by his son Suleiman, whose reign was of little consequence.