In 1768, the Spanish, under the approval of King Louis XV of France, assigned O'Reilly to suppress the Louisiana Rebellion and punish those responsible for deposing Antonio de Ulloa, the former Spanish governor of Louisiana. He arrived largely unopposed in New Orleans in August 1769, as the leaders of the French Creole rebellion had urged citizens to avoid military confrontation and accept Spanish authority.
In order to quell the rebellion, O'Reilly had six of its leaders executed. He also introduced "O'Reilly's Code", which embodied the laws of Castile and of the Indies, thus aligning Louisiana's legal system with that of Spain. Additionally, O'Reilly eased restrictions on the emancipation of slaves.