HONG KONG — The democracy activist Joshua Wong was sentenced to three months in prison on Wednesday for his role in a protest in 2014 demanding freer elections for the leader of this semiautonomous Chinese territory.

Mr. Wong had pleaded guilty to contempt of court for refusing to obey a court order to leave a protest site in the last days of demonstrations, known as the Umbrella Movement, that paralyzed parts of Hong Kong without winning any political concession from the Chinese government.

“They can lock up our bodies, but they cannot lock up our minds,” Mr. Wong, a leader of the political party Demosisto, told reporters outside the High Court in Hong Kong before his sentencing.

The prison term dealt the latest blow to Mr. Wong, who was sentenced in August to six months in prison after he was found guilty of unlawful assembly. The city’s highest court, the Court of Final Appeal, began hearing an appeal of that prison term on Tuesday.