He was viceroy for less than four months, from June to October 1664. He was named to the position to replace Viceroy
Juan Francisco Leiva y de la Cerda, who was ordered back to Spain because of corruption. Osorio apparently accepted the position with reluctance. He was a stranger to profane affairs, and resigned as viceroy at the first opportunity in order to return to his diocese in Puebla. During his brief administration, he sent 30,000 pesos to Cuba for the repair of the Castle of
Santiago and the rebuilding of the city, which had been destroyed by the English in 1662. He also founded a gunpowder factory and sent some of the production to Cuba. He took steps to see that the Armada de Barlovento was prepared for an attack on the Gulf coast of New Spain. He advanced money for the fortification of
Campeche. Spain was still at war with England. He reformed the postal service, which was very bad before his administration and much more efficient after his reforms. He also reformed the marketing of mercury and intervened in a dispute between the Franciscans and the governor of Yucatán. ==Return to Puebla==