BAMAKO, Mali — The president of Ghana, John Atta Mills, died unexpectedly Tuesday at a military hospital in the capital, Accra, five months short of finishing his first term in office. He turned 68 on Saturday.

News of his death came on state-run television, which interrupted regular programming for the announcement. The government gave no details of the cause, but Mr. Mills had recently spent eight days in the United States for medical treatment.

He did not disclose what treatment he was seeking, but told his fellow citizens on his return that he was strong enough to run the country. But on Tuesday afternoon, he was rushed to the military hospital, where he died.

Mr. Mills, a former university economics professor, was narrowly elected at the end of 2008, by less than 1 percent of the vote. He was due to run again in elections in December. In 2009, President Obama chose Ghana for his first African visit — testimony to the solidity of the country’s democracy — and in 2011, Ghana began exporting oil for the first time, sending out 23.5 million barrels that year.