Ghanaian President John Atta Mills vowed to help spread the wealth from Ghana’s newly discovered offshore oil fields, but his death July 24 came before the 68-year-old could finish his first term in this West African nation long held up as a model of democracy.

Ghanaian state-run television stations broke into their regular programming to announce the president’s death. Chief of Staff John Henry Martey Newman told the nation that Mr. Mills died at a military hospital in the capital, Accra. No details were provided about the cause of death, but some news accounts said he had throat cancer. Vice President John Mahama was sworn in Tuesday to complete the last 51 / 2 months of Mr. Mills’s term.

Chris Fomunyoh, the senior director for Africa for the Washington-based National Democratic Institute for International Affairs, said that Ghana’s democracy could weather the death of a president.

In other nations in West Africa, the death of a ruler usually spells a coup, as it did in Guinea after the 2008 death of longtime dictator Lansana Conte, and Togo, where the military seized power after the president’s death in 2005 to install his son.

Ghana, whose economy has been fueled by gold, cocoa and timber exports in the past, hopes to put its oil money to good use, mindful of how nearby Nigeria suffered through military dictatorships and widespread corruption over its oil wealth.

Mr. Mills was elected in a 2008 runoff vote — his third presidential bid — after campaigning on a platform of change, arguing that the country’s growth had not been felt in people’s wallets.

“People are complaining. They’re saying that their standard of living has deteriorated these past eight years,” he told the Associated Press in 2008. “So if Ghana is a model of growth, it’s not translating into something people can feel.”

Mr. Mills even put up campaign posters of himself standing next to a cutout of President Obama in an effort to emphasize that he, too, stood for change.

In March, Mr. Mills traveled to the United States, where he met with Obama. The Ghanaian leader traveled to the United States in April as well, as rumors about his health began to circulate in Ghana. Opposition newspapers had recently reported that that he was not well enough to run for a second term.

Mr. Mills won the 2008 second-round ballot capturing a razor-thin victory with 50.23 percent of the vote — or 4,521,032 ballots. His opponent, Nana Akufo-Addo, garnered 49.77 percent — or 4,480,446 votes.

Mr. Mills also served as vice president under Jerry Rawlings, a coup leader who was later elected president by popular vote and surprised the world by stepping down after losing the 2000 election.

John Evans Atta Mills was born July 21, 1944, in Tarkwa, Ghana. He spent much of his career teaching at the University of Ghana. He earned a doctorate from London’s School of Oriental and African Studies before becoming a Fulbright scholar at Stanford University in Palo Alto, Calif.

Survivors include his wife, the former Ernestina Naadu, and a son.

— Associated Press

Sammy Ajei and Jon Gambrell in Lagos, Nigeria, and Laura Burke in Cape Coast, Ghana, contributed to this report.