The islands were settled from the second century AD by a series of local empires. In 1819, Sir Stamford Raffles founded Singapore as a trading post of the East India Company; after the company collapsed, the islands were ceded to the United Kingdom of Great Britain and Ireland and became part of its Straits Settlements in 1826. During World War II, Singapore was invaded and occupied by Japan.