On 20 September 1840 a revolt of the garrison in San Salvador led by General Francisco Malespín forced the resignation of Ramírez's predecessor, Colonel Antonio José Cañas.
Ramírez handed over command to Lindo the same day, and he proceeded to be deputy chief along with Pedro José Arce and Joaquín Eufracio Guzmán who replaced Villacorta.
Ramírez ordered the commander of the army, Fruto Chamorro, to suppress constant revolts led by the liberal General Bernabé Somoza.
At the end of 1849, the supreme director sent the lawyer Eduardo Carcache to the city of Washington as extraordinary and plenipotentiary minister of Nicaragua in the United States, Carcache being the first with this position, he was commissioned by the Nicaraguan government to try to obtain the signing of a treaty on an interoceanic canal by Nicaragua and to win the support of the United States in the conflict with England regarding the occupation of the San Juan River and the Mosquito Coast.
On 25 July that same year, the Treaty of Peace and Friendship with Spain was signed, which definitively recognized the independence of Nicaragua.