Conversation so far:
who was named protector of peru after liberating the country from spanish rule
On 12 July 1821, after seizing partial control of Lima, José de San Martín was appointed Protector of Peru

Question: when was the country liberated
Self-contained rewrite: when was peru liberated