A United States Navy veteran held in Iran since July while visiting an Iranian girlfriend has been sentenced to 10 years in prison on charges that he insulted the country’s top leader and posted a private photograph on social media, his family’s lawyer said Friday.

The lawyer, Mark Zaid, said the family had been informed earlier this week by the State Department of the sentencing of the veteran, Michael R. White, 46, of Imperial City, Calif.

The information was conveyed to the State Department by Swiss diplomats who represent American interests in Iran, Mr. Zaid said in a telephone interview. He said Mr. White, who has been incarcerated in the northeast city of Mashhad since his arrest eight months ago, has twice been granted Swiss consular visits.

Mr. White served in the Navy for 13 years and is the first American imprisoned in Iran since President Trump took office more than two years ago.