Ukraine’s opposition movement gained ground Tuesday in its efforts to remake the country, with the resignation of the prime minister and his cabinet and the repeal of harsh new laws restricting freedom of speech and assembly.

Ukraine’s parliament, the Verkhovna Rada, invalidated the anti-demonstration laws hours after Prime Minister Mykola Azarov resigned. Passage of the legislation on Jan. 16 had triggered street clashes in the capital, Kiev, after months of protests against government corruption and the closer ties to Russia favored by President Viktor Yanukovych.

The unraveling of the government has the potential to become a severe blow to Russian President Vladimir Putin, who strove to prop up Yanukovych and keep Ukraine from drawing closer to the West.

Parliament passed an amnesty bill Tuesday that would drop criminal liability for protesters who agree to leave the government buildings they have occupied. But the opposition objected to the terms, and the bill is to be reconsidered Wednesday. Vacating public buildings has been a key government demand, but Oleh Tiahnybok, head of the opposition Svoboda party, said protesters would remain in the buildings until Yanukovych’s Party of Regions leaves the government.

Another leading opposition politician, Arseniy Yatsenyuk of the Fatherland party, said he expects parliament to appoint a commission Wednesday to rewrite the constitution, potentially the most far-reaching of the changes being broached this week.

Yanukovych said over the weekend that he would be willing to cede considerable power to parliament under a new constitution. Some of his opponents have suggested that he would be content to stay on as a figurehead if that is the only way he can keep his job — and his immunity from prosecution.

Yanukovych had offered Saturday to make Yatsenyuk prime minister and another opposition leader, Vitali Klitschko, deputy prime minister. Both men, reluctant to be drawn into collaboration with the president, demanded further negotiations. Klitschko said Tuesday that he would not serve in a new government under Yanukovych.

Azarov, the prime minister who resigned Tuesday, was a leading skeptic about a proposed trade agreement with the European Union. He said the pact came bristling “with thorns,” and his view seemed to have prevailed in late November, when Yanukovych abruptly walked away from the deal.

Yanukovych then sought help for Ukraine’s battered economy from Putin, who responded with a $15 billion aid package.

That aid, Russian officials said Tuesday, could be in jeopardy, depending on political developments in Ukraine.

The protests in Kiev started Nov. 21, almost immediately after Yanukovych abandoned the deal with Europe. Unlike protesters in Russia in recent years, demonstrators in Kiev dug in and created a barricaded encampment that police have been unable to budge.

After parliament passed the ­anti-protest laws — on a voice vote less than a minute after they were introduced — clashes with police began to develop on nearby Hrushevsky Street. At least four demonstrators were killed.

New protests broke out almost simultaneously in western Ukraine and, over just a few days, spread to the eastern, Russian-speaking heartland of Yanukovych’s Party of Regions.