An American student from Princeton University was arrested in Iran and has been sentenced to 10 years in prison on charges he was spying for the United States, an Iranian judiciary official said on Sunday, an action bound to aggravate relations between the two countries.

The arrest and sentencing of the American, Xiyue Wang, a graduate student in history, was announced months after he had vanished in Iran, where he was doing research for a doctoral thesis. There had been rumors of his arrest, but the announcement on Sunday from Iran was the first official confirmation.

A spokesman for Iran’s judiciary, Gholam Hossein Mohseni-Ejei, said at a weekly news conference that one of “America’s infiltrators” had been prosecuted, but he did not identify Mr. Wang by name or nationality. The judiciary’s Mizan News Agency provided his name and his age, 37, saying he had “spider connections” with American and British intelligence agencies.

Mizan also said Mr. Wang, whom it described as fluent in Persian, had digitally archived 4,500 pages of Iranian documents and had done “super confidential research for the U.S. Department of State, Harvard Kennedy School and British Institute of Persian Studies.”