Morazán returned in 1842 and seized power in Costa Rica, seeking to make it a base for restoration of the federation. He found little support for this and was himself ousted by Costa Rican Conservatives and executed in San José on Sept. 15, 1842.
In 1842 he returned to attempt the restoration of the federation. He attacked and defeated the forces of the Costa Rican dictator Braulio Carillo, but when he tried to follow up this triumph, his forces were quickly routed. Betrayed and captured, Morazán was executed by a firing squad.