Answer
The final Spanish stronghold José de San Martín attacked during his campaign for South American independence was Lima, Peru, the capital of the Viceroyalty of Peru. By capturing Lima in July 1821, San Martín and his forces dealt a significant blow to Spanish rule in South America and paved the way for the independence of Peru.