 Within six months, the new army was in control of all but the ports of Veracruz and Acapulco.On September 27, 1821, Iturbide and the last viceroy, Juan O'Donojú signed the Treaty of Cordoba whereby Spain granted the demands.O'Donojú had been operating under instructions that had been issued months before the latest turn of events.