On WeChat, some users posted “Bloodstained Glory,” a song originally written to commemorate the People’s Liberation Army and covered by Peng Liyuan, the wife of President Xi Jinping, but since co-opted to recall the 1989 massacre. The posts were later taken down.

Others marked the anniversary privately, such as by fasting or holding candlelight vigils at home.

In Hong Kong, mainland tourists were among the visitors on Tuesday at the June 4th Museum, which was opened this spring by a pro-democracy group. They took photographs of the exhibits and discussed how to hide related books and pamphlets from mainland border officials when they returned home.

“There are too many lies and incomplete information in mainland China, so I came here for an ounce of truth,” said Mr. He, a man in his 50s who declined to provide his full name because of the sensitivity of the subject.

Mr. He came from the northern Chinese autonomous region of Inner Mongolia to visit the museum and participate in the Hong Kong vigil. Organizers estimated Tuesday night that more than 180,000 people had attended that event, far more than last year. The police, whose estimate is usually much lower, said the event had drawn 37,000 people at most.

Turnout for the vigil has become a barometer of local discontent, and organizers had said they expected more people to show up not just because of the 30th anniversary, but also to vent growing anger over a government proposal to allow extraditions to the mainland for the first time.

The proposal has been criticized by foreign governments, human rights groups, lawyers and business associations. It inspired the biggest protests the city has seen since the 2014 Umbrella Movement and scenes of chaos in the city’s legislature as opposition politicians tried to thwart its progress.