RIO DE JANEIRO — Leopoldo López, Venezuela’s most prominent political prisoner, was released from a military prison on Saturday morning and transferred to house arrest in a surprise move that could invigorate the protest movement against President Nicolás Maduro’s government.

Political allies and one of Mr. López’s lawyers described the release as a sign that the government was starting to buckle in the face of months of public demonstrations and growing diplomatic isolation.

“This is a step toward freedom, not just Leopoldo’s, but also a step that brings all Venezuelans closer to freedom,” a lawmaker, Freddy Guevara, told reporters outside Mr. López’s home, where supporters chanted “Yes, we can!”

Jared Genser, an American human rights lawyer who has represented Mr. López, said his client’s release was a unilateral concession by the government that took Mr. López’s relatives and legal team by surprise.