In between the two marches, a demonstration outside the local legislature turned violent on Wednesday when protesters trying to storm the building were met with tear gas and rubber bullets from riot police officers. Many protesters cited the police response as one of their reasons for joining the march on Sunday.

Mr. Wong told reporters on Monday that unless Ms. Lam resigned, “more and more Hong Kong people, not only one million or two million people, will come and join our fight until we get back our basic human rights and freedom.”

He later appeared outside the legislature, where protesters greeted him with uproarious applause and cheers. He said he had been following the anti-extradition movement from prison and thanked those who had protested the bill. Mr. Wong, who said he had not yet changed out of the clothes he was wearing when he entered prison, told the crowd he was ready to join the fight after taking some time to adjust.

The protests this month have been mostly leaderless. A local civil rights group received permits for the two Sunday marches, but the protest on Wednesday developed organically through social media and messaging apps.

But in 2014, Mr. Wong was among the clear leaders of the sit-in known as the Umbrella Movement, in which thousands of students and other demonstrators blocked major roadways for 79 days as they called for freer elections. While the movement failed to meet its short-term objectives, it was a formative experience for many young activists and its influence has been apparent in the anti-extradition protests.