BEIRUT, Lebanon — Saudi Arabia has freed a doctor with dual Saudi-American citizenship after he was detained for 21 months and reportedly tortured, two friends of the family said on Thursday.

The Saudis first detained Dr. Walid Fitaihi in November 2017 amid what the government called a crackdown on corruption. Despite Dr. Fitaihi’s lengthy detention, the Saudi government has never explained the reason for his arrest and has not said whether he was ever charged with a crime.

On Thursday, a Saudi official said that Mr. Fitaihi had been released pending trial, in part because of a provision in the kingdom’s counterterrorism and terrorism finance law, suggesting that he faced charges connected to that law.

He is one of hundreds of Saudis who have been detained in recent years as Saudi Arabia’s de facto ruler, Prince Mohammed bin Salman, has secured his grip on power. The detainees have included prominent businessmen and government ministers, members of the royal family, clerics, intellectuals and activists who have campaigned against the kingdom’s restrictions on women.