Over the past few years, Saudi Arabia has spent millions of dollars trying to remake its image on the international stage. It has hired prominent U.S. lobbying and public-relations firms to push its message in Washington.

To what end? The kingdom has an ambitious plan to dramatically reform its economy, for which it will need Western investors. It also wants to reshape the geopolitics of the Middle East in its favor by thwarting Iranian influence and isolating neutral countries, such as Qatar.

However, Saudi Arabia's reputation continues to be a problem. It has long been associated with religious extremism and dogged by accusations of terrorism funding. It also imposes severe restrictions on women. This week, reports that a young woman was arrested in Saudi Arabia after she appeared in a video wearing a short skirt prompted global outrage.

The situation coincides with several damaging reports claiming that a recent shake-up in the Saudi leadership was far tenser than publicly acknowledged.

The controversy over the video began when it was posted to the social network Snapchat by a user named “Khulood” during the weekend. In a string of brief clips, an unidentified woman was shown walking through an ancient fort in Ushayqir, a village about 95 miles from the capital, Riyadh, in the socially conservative Najd region, wearing a skirt and a top that revealed her midriff.

In Saudi Arabia, this sort of attire in public is taboo. The country, which follows a strict interpretation of Islam, has customs that require women to cover themselves while in public by wearing a loosefitting cloak called an abaya. Most Saudi women also wear some kind of hijab, a head covering; others opt to cover their faces further with a niqab.

Though the attire of the woman in the video wouldn't be out of place in many parts of the Middle East — or even some exclusive parts of Saudi Arabia itself — the video soon sparked a backlash among Saudi social media users.

A hashtag calling for the woman's arrest quickly spread on Twitter and Facebook, with prominent Saudis voicing support for such a move. “Just like we call on people to respect the laws of countries they travel to, people must also respect the laws of this country,” writer Ibrahim al-Munayif wrote on his Twitter account, which has more than 40,000 followers.

On Tuesday, state television said that police in Riyadh had arrested the woman “who appeared in suggestive clothing” and that her case had been referred to prosecutors.

On Wednesday, however, Saudi Arabia's Center for International Communications released a statement saying the woman had been allowed to go after just a few hours of questioning. The statement also said that she would not face charges and that the case was closed.

But this did not stop the international uproar. Social media users worldwide reacted angrily to reports of the arrest — some comparing the woman to American civil rights activist Rosa Parks; others observed that Saudi Arabia had only recently been voted onto a United Nations body intended to promote women's rights.

The controversy served as another reminder of the restrictions placed on women in Saudi society. In addition to rules about how they must dress, women must get the permission of a “male guardian” for work or travel, and they are blocked from getting driver's licenses. In the World Economic Forum's 2016 global-gender-gap ranking, Saudi Arabia stood at 141 out of the 144 countries listed.

Saudi leaders have long hinted at reform. An ambitious plan to reimagine Saudi Arabia's economy, known as Vision 2030, includes proposals to increase the number of women who work and who attend university. Crown Prince Mohammed bin Salman, the powerful 31-year-old spearheading these plans and widely expected to soon be king, has indicated that he is open to women driving, though he has doubts that the country is ready for it.

Sarah Leah Whitson, executive director of Human Rights Watch's Middle East and North Africa division, said that the events this week cast doubt on these proposals. “Saudi Arabia’s purported plans to reshape society and advance women’s rights will never succeed as long as authorities go after women for what they wear,” Leah Whitson said in an emailed statement earlier this week.

The situation also juxtaposes awkwardly with Saudi Arabia's campaign against Qatar. Juan Cole, a history professor at the University of Michigan and a prominent Middle East commentator, wrote on his blog that Saudi Arabia's strict dress code for women appears hypocritical given that the kingdom claims to be combating extremism. “Saudi Arabia is leading a propaganda campaign falsely accusing Qatar of supporting extremism in the Middle East, but it just arrested a young model named Khulud for taking a walk at a historic site in Najd wearing a halter and a skirt,” Cole wrote Wednesday.

Mohammed, the crown prince, also plays a significant role in the dispute with Qatar, as well as an ongoing military campaign in Yemen. Many news outlets reported this week that he had orchestrated the ousting of his cousin Mohammed bin Nayef, formerly next in line to the throne and now being confined to his home.

Details of what happened to the woman in the video and why she was released were not available. The Saudi legal system is notoriously opaque; the Saudi Embassy in Washington and the Center for International Communications did not respond to requests for more information. In the past, Saudi political leaders have stepped into controversial or extreme legal cases.

The arrest of the woman offended many Saudis. On social media, many users based in the kingdom argued that the rules about how women should dress were often not followed by Saudis when they went abroad, nor by foreigners when they visited Saudi Arabia. One sardonic tweet shared by a Saudi Twitter user crudely superimposed Ivanka Trump's face onto that of the woman with the caption: “Enough already, the situation has been solved.”

The considerable backlash over the video and the confused official response suggest that Saudi Arabia is divided on social issues. And with reports of infighting in the Saudi royal family, as well as a shaky-looking economic and geopolitical future, these divisions are unlikely to be solved anytime soon.

Correction: An earlier version of this article incorrectly said that all women in Saudi Arabia are legally required to wear the abaya. The story has been updated to show that this is a widely followed custom, not a legal requirement.

More on WorldViews:

Saudi Arabia says woman arrested for wearing skirt in viral video has been released

Trump once denounced Saudi Arabia as extremist. Now he’s heading there to promote moderate Islam.