On January 22, 1640, López Pacheco was named viceroy, under King Philip IV of Spain. He arrived in Veracruz on June 24 of that year, together with Juan de Palafox y Mendoza, bishop of Puebla. The bishop had been commissioned visitador general to begin proceedings against the two previous viceroys, Rodrigo Pacheco, 3rd Marquess of Cerralvo and Lope Díez de Armendáriz, marqués de Cadereyta. López Pacheco was delayed some months in the port by the festivities celebrating his arrival. He made his solemn entry into Mexico City on August 28. He soon found himself popular, in spite of the introduction of tax stamps and remitting of more tribute to Spain. While still in Veracruz, he was informed of the pressing need to reinforce the Armada de Barlovento, which guarded the coast and shipping from corsairs. He immediately took up this project, renovating six warships, ordering the construction of others, and obtaining several more from Cartagena and Havana. He ordered the casting of cannons and the production of munitions, gunpowder and rigging. In 1641 Luis Cetin de Canas, governor of Sinaloa solicited and obtained the viceroy's approval to send an expedition to colonize the Californias with Jesuit missionaries. This was not successful. Also during López Pacheco's term, a change occurred in the parish churches of the colony; a majority of them were now held by secular clergy rather than the regular friars.
Revolution in Portugal
In the previous year a revolution broke out in Portugal, and the Duke of Braganza, a first cousin of the viceroy, was crowned King John IV, initiating the Portuguese Restoration War. This naturally led to questions about the viceroy's loyalty. To allay the suspicions, López Pacheco ordered that all Portuguese residents in New Spain register with the government, for control of their movements, possessions and activities. However, he remained under suspicion. The visitador general, Bishop Palafox y Mendoza, who was already involved in proceedings against earlier viceroys, broke with the current viceroy in 1642, accusing him again of being in league with Portugal. This was probably on orders from the Crown — at least Bishop Palafox claimed to have the orders, although he did not show them. The bishop arrived secretly in the capital, and in the middle of the night of June 9/10, he met with the Audiencia and laid out his suspicions. He then ordered that the viceregal palace be surrounded by guards. The following morning Viceroy López Pacheco was informed that the bishop had been named archbishop and viceroy. López Pacheco was moved to the convent of Churubusco as a prisoner, and a few days later he was moved out of the capital to San Martín Texmelucan. His possessions were confiscated and sold at public auction. A few months later he returned to Spain, where after a short trial he was found innocent of the accusations against him. The king restored part of the money he had lost through confiscation and offered to restore the viceregency, but López Pacheco was not willing to return to Mexico. The king instead made him governor of Sicily, and later viceroy of Navarre.