In 1762, in the infamous Treaty of Fontainebleau, Louis XV of France secretly granted New Orleans and the area of Louisiana west of the Mississippi to his cousin Charles III of Spain. By the time Louisiana was handed over to Spain, the colony was in trouble. For decades colonists, many lured by the promises of prosperity, had struggled to survive floods and famine and the general neglect of the colony by the French crown. Through improved management and the encouragement of settlement, the Spanish transformed New Orleans into a growing seaport and commercial hub. Despite a period of rebellion by French loyalists, Louisiana remained under Spanish control until 1800.