HONG KONG — A Chinese journalist and democracy advocate who had been imprisoned since 2005 after Yahoo provided information about his e-mail account to the government in Beijing has been released, his associates said Saturday.

The journalist, Shi Tao, who worked in the central city of Changsha, was arrested by the Chinese authorities in 2004 for leaking “state secrets” abroad and was sentenced to a 10-year prison term in April 2005. He had used his Yahoo e-mail account to send messages to an online forum, based in New York, about a Chinese propaganda directive censoring domestic news media coverage of the 15th anniversary of the 1989 Tiananmen Square massacre.

Mr. Shi, who is also a poet, was released from a prison in the city of Yinchuan, in the northwest Ningxia region, on Aug. 23, Zhang Yu, the deputy secretary general of the Independent Chinese PEN Center, part of the PEN International organization of writers, said Saturday. Mr. Shi is now staying with his mother in Yinchuan, and in phone conversations over the past week he said he “felt generally well,” according to Mr. Zhang.

It was not immediately clear why Mr. Shi, who had served less than nine years, had been released before the completion of his sentence. He was transferred to Yinchuan from a prison in central Hunan Province in 2010.

Yahoo was widely criticized for sharing information with the Chinese authorities on the activity of Mr. Shi’s e-mail account — as well as similar information about another Chinese dissident, Wang Xiaoning. Mr. Wang was released from prison in 2012 after serving a 10-year sentence on charges of “inciting subversion of state power” after he circulated pro-democracy messages using Yahoo e-mail and online forums.

The company has maintained that it was complying with Chinese law when its Hong Kong unit turned over the information on the e-mail accounts. In a November 2007 Congressional hearing into the matter, Yahoo’s co-founder and its chief executive at the time, Jerry Yang, apologized to the families of Mr. Shi and Mr. Wang. Shortly afterward, the company settled lawsuits brought by the two men.

In the past month, Yahoo China, which had been operated through a partnership with the Chinese Internet giant Alibaba, has discontinued its dedicated Web portal in the country, as well as its e-mail services.