HONG KONG — Hundreds of people in Hong Kong lined up on Saturday to visit China’s first aircraft carrier, the Liaoning, which is making a five-day port call here to commemorate the 20th anniversary of the former British colony’s return to Chinese rule.

The ship’s visit is part of efforts to raise the profile of China’s military and inspire patriotism in the semiautonomous city, analysts and officials said. Hong Kong has been the site of large street protests in recent years as calls for increased local autonomy and even independence grow. Young people are increasingly likely to call themselves “Hong Kongers” instead of “Chinese,” which local officials say they want to change.

The carrier’s visit is intended to send several messages, said Jean-Pierre Cabestan, a professor of government and international studies at Hong Kong Baptist University.

“The first, to Hong Kong society, is to remember that you are Chinese and Hong Kong is part of China,” he said. “The second message is to be proud of being Chinese, because now we are a powerful force to be reckoned with, on par with the United States.”