In this state of perpetual war, government rapidly became exclusively military. On the surface the contest seemed only a struggle between two sets of independent chiefs, in whose mouths "liberty" and "loyalty" were mere catch-words, and who continually quarrelled among themselves even when they nominally belonged to the same side. Early in 1812 Montufar was overthrown by another Creole chief in Quito who thereupon undertook an expedition against the Spanish general at Cuenca. But sedition among the patriot troops gave an easy victory to the latter, and the Spaniards took the offensive. Marching toward Quito, they dispersed the patriot army at Mocha, and entered the capital in triumph.
Montes, the Spanish general who now became ruler of the presidency, was a wise and moderate man, and spared no pains to conciliate. He soon succeeded in so completely consolidating his power that during nine years Quito and most of the presidency remained quietly submissive, and became one of the centres whence Spanish expeditions went out against the parts of the continent which still remained in revolution. An able general, Samano by name, carried the successes of the Spanish arms to the north, and although the patriots of Colombia obtained some temporary advantages in the winter of 1814-15, they never penetrated south of Pasto. In 1816 the tide again turned with the arrival of eleven thousand Spanish veterans in the north of Colombia. The patriots were soon everywhere defeated, Bogotá itself taken, and a remnant of revolutionists who attempted the invasion of Popayan and Pasto were overwhelmed by Samano in 1816 at the battle of Tambo. The patriot cause was at its lowest ebb in all South America. Resistance ceased in Colombia; only a few scattered bands kept up a desultory warfare in Venezuela; Ecuador, Peru, and Bolivia were quiet; Spanish authority had been re-established in Chile; Uruguay had fallen into the hands of the Portuguese king; and Spanish armies were invading the Argentine, the last refuge of the revolution.
San Martin's thunderbolt descent upon Chile and his victory at Chacabuco changed the aspect of affairs. A fleet was improvised at Valparaiso which obtained command of the Pacific coast, cutting off the Spaniards in Ecuador from receiving supplies except overland from the Caribbean ports. Bolivar took new heart for his tedious task of arousing the north and driving the Spaniards from Venezuela and New Granada. In 1819 he climbed the east side of the Andes to the neighbourhood of Bogotá and by defeating the Spanish army at Boyacá, freed most of present Colombia, and even in Quito the patriots renewed their revolutionary plotting. Meanwhile San Martin had completed the expulsion of the Spaniards from Chile, and in 1820 he transported an army by sea to the neighbourhood of Lima itself, opening communications with the anti-Spanish party all along the coast. On the 9th of October, 1820, a successful revolution broke out at Guayaquil, and little time was lost in sending an army to the plateau. The Spaniards defeated it, but with Bolivar threatening them from Colombia, their comrades in Peru fighting for their lives against San Martin, the population of Quito on the verge of a revolt, and the Pacific in the control of the patriots, they could not follow up their advantage.
On June 24, 1821, Bolivar gained the crowning victory of Carabobo in Venezuela. The Spanish position in the Caribbean provinces became irretrievable, and the patriot general was thenceforth free to pursue his plans for the expulsion of the enemy from southern New Granada and Ecuador and their incorporation with Colombia. In the fall of that year General Sucré, who shares with San Martin the honor of being the greatest soldier of the patriot side, arrived at Guayaquil by sea, bringing with him seventeen hundred Colombian and Venezuelan veterans. Bolivar was to advance from Bogotá, conquering Popayan and Pasto on his way to Quito, while Sucré came up from the south. The latter at once ascended the Andes to the plateau, but was badly defeated. Retreating to Guayaquil, he reorganised his army, incorporating with it a reinforcement of twelve hundred men sent by San Martin, and again climbed the Andes. By this time Bolivar was advancing from Popayan to Pasto and the Spaniards, thinking it best to concentrate their forces, abandoned Cuenca and the southern provinces and allowed Sucré to advance unopposed to the neighbourhood of Quito. There he outmanœuvred them and gained a commanding position on the slopes of the great volcano, Pichincha, overlooking the city. His foes were forced to the alternative of giving battle at a disadvantage or permitting him to effect a junction with Bolivar, and overwhelming them by superior numbers. On the morning of the 24th of May, 1822, the battle decisive of Ecuador's fate was fought. The royal army suffered annihilation; four hundred dead lay on the mountainside and two hundred wounded; eleven hundred men and one hundred and sixty officers surrendered the following day. The only troops who escaped belonged to scattered detachments not present at the battle, who fled down the eastern slope of the Andes into the trackless forests and finally made their way down the Amazon to the Atlantic.