A short synopsis of the intertwined history of the Johor Sultanate and that of Temasek is as follows:
Singapore and the British
In 1818, Sir Stamford Raffles was appointed as the governor of Bencoolen on western Sumatra. However, he was convinced that the British needed to establish a new base in Southeast Asia in order to compete with the Dutch. Though many in the British East India Company opposed such idea, Raffles managed to convince Lord Hastings of Company, then Governor General of British India, to side with him. With the governor general's consent, he and his expedition was set to search for a new base.
Raffles' expedition arrived in Singapore on January 29, 1819. He discovered a small Malay settlement at the mouth of Singapore River headed by a Temenggung (governor) of Johor. Though the island was nominally ruled by the sultanate, the political situation there was extremely murky. The current sultan, Tengku Abdul Rahman, was under the influence of the Dutch and the Bugis. Hence, he would never agree to a British base in Singapore.
However, Tengku Abdul Rahman was ruler only because his older brother, Tengku Hussein or Tengku Long, had been away in Penang getting married when their father died in 1812. According to Malay culture, a person has to be by the dying sultan's in order to be considered as the new ruler. The older brother wasn't happy with the development. Furthermore, the Temenggung preferred Tengku Hussien to the younger brother.
Upon learning Johor political scenario, Raffles made a deal with Tengku Hussein. The agreement states that the British would acknowledge Tengku Hussien as the legitimate ruler of Johor. Tengku Hussein and the Temenggung would receive yearly stipend from the British. In return, Tengku Hussein would allow Raffles to establish a trading post in Singapore. The treaty was ratified on February 6, 1819.
With the Temenggung's help, Raffles managed to smuggle Hussein, then living in exile on one of the Riau Islands, back into Singapore.
The Dutch was extremely displeased with Raffles' action. However, with the signing of Anglo-Dutch Treaty of 1824, the Dutch receded its opposition to British's presence in Singapore. The treaty also divided the Sultanate of Johor into modern Johor and the new Sultanate of Riau.
In the new Johor, though Tengku Hussein was the sultan, the Temenggung was the one that run Johor. The Bugis on the other hand controlled Riau.
Modernization
In 1855, under a treaty between the British in Singapore and Sultan Ali of Johor, the control over the state was formally ceded to Temenggung Ibrahim, with the exception of Muar. Muar was later handed over to the Temenggung's control in 1877. Temenggung Ibrahim opened up Bandar Tanjung Puteri in southern Johor as a major city. Bandar Tanjung Puteri would later be known as Johor Bahru.
Temenggung Ibrahim was succeeded by his son, Temenggung Abu Bakar, who later took the title Seri Maharaja Johor. In 1866, he was formally crowned the Sultan of Johor. Sultan Abu Bakar introduced a constitution and developed an efficient administration system. He also ordered the constrution of Istana Besar, the official residence of the sultan. Due to these achievements, Sultan Abu Bakar is known by the title "Father of Modern Johor".
Johor also enjoyed economic prosperity. An increased demand for black pepper and gambier in the nineteenth century lead to the opening up of farmlands to the influx of Chinese immigrants, creating Johor's initial economic base. The Kangchu system was put in place.
In 1914, Sultan Ibrahim, Sultan Abu Bakar's successor, was forced to accept a British Resident and effectively became a crown colony of the Britain. D.G. Campbell was dispatched as the first British advisor to Johor.