BEIJING — The photos prompted outrage almost as soon as they were posted.
They showed two women inside one of China’s most sacred spaces, the Forbidden City in Beijing, smiling as they showed off a glistening Mercedes-Benz sport utility vehicle.
On Weibo, a Twitterlike site, one of the women bragged about getting exclusive access to the palace, a notoriously congested tourist site, saying she had gone there to “run wild.”
The photos, which were posted on Friday, have set off debate in China about the privileges enjoyed by wealthy families, at a time when President Xi Jinping is trying to persuade the public that he is working to eliminate corruption and to reduce the gap between rich and poor.
Many people denounced the woman, who had frequently boasted about her wealth on social media, as being out of touch. They said she had desecrated the Forbidden City, the former home of emperors, which Mr. Xi has sought to turn into a global symbol of Chinese cultural heritage.
“Don’t roll your privileges over China’s face,” wrote a Weibo user named Ding Lei.
The palace is typically closed to vehicles, and it was unclear how the woman and the Mercedes had gained access.
The Palace Museum, which was also widely criticized on social media, acknowledged in a statement on Friday that a car had entered the Forbidden City on Monday, while it was closed to the public, but gave no other details. Officials at the museum said they were “deeply distressed” by what had happened, and they vowed to impose “strict management” to prevent future mishaps.
The woman who posted the photos under the user name Lu Xiaobao LL initially defended her behavior, saying in a follow-up post that she was at the Forbidden City to see an exhibit.
“It’s not illegal to take a picture, right?” she wrote, according to screenshots published by the Chinese news media. “It is fine if you guys don’t know that but it is really not O.K. to curse.”
Her social media posts, which drew widespread ridicule, have since been erased, and she did not immediately respond to a message on Saturday seeking comment.
Photos of the woman’s visit spread swiftly across China’s internet, drawing hundreds of thousands of comments and inspiring an outpouring of memes and commentary.
Some people posted novellas describing the imagined life of a wealthy Beijing ingénue looking for adventure. Others circulated fake advertisements for Mercedes-Benz, boasting that its vehicles could traverse any terrain, even the Forbidden City.
The widespread anger over the photos reflects anxieties in Chinese society about the privileges enjoyed by well-connected individuals, analysts said, at a time when the government is promising equal access to education, health care and social services.
“Before, people in China accepted that there was a gap between rich and poor,” said Yik Chan Chin, a lecturer in media and communication studies at the Xi’an Jiaotong-Liverpool University in Suzhou, China. “Now, they no longer accept this gap.”
That poses a challenge for Mr. Xi, who has spoken frequently about his desire to reduce economic inequality and to eliminate corruption.
“From the party’s perspective, you want to maintain domestic stability and don’t want to have these kinds of small issues, which might trigger broader backlash,” Professor Chin said.
On Saturday, the Chinese government, which strictly controls the internet, appeared eager to limit discussion of the topic, censoring some posts on Weibo and other social media networks.
The People’s Daily, the official newspaper of the ruling Communist Party, published a commentary on Saturday saying that a national relic had been violated.
“Under the rules, everyone is equal,” the newspaper wrote. “No one has the privilege to ‘run wild.’ ”
Albee Zhang contributed research.