GARSEN, Kenya — Eritrea, a sliver of a nation in the Horn of Africa that is one of the most secretive and repressive countries in the world, was cast into confusion on Monday after mutinous soldiers stormed the Ministry of Information and took over the state-run television service, apparently in a coup attempt.

According to several people with close contacts inside Eritrea, the coup attempt failed, with government troops quelling the would-be rebellion and no one rising up in the streets. But many analysts said it was only a matter of time before President Isaias Afwerki, Eritrea’s brash and steely leader for the past 20 years, is confronted again — and most likely from within.

“There’s a lot of dissatisfaction within the armed forces,” said Dan Connell, a professor at Simmons College in Boston and the author of several books on Eritrea. “If this is suppressed, it won’t be the end.”

Eritrea is often called the North Korea of Africa because it is so isolated and authoritarian, with few friends and thousands of defectors in recent years as Mr. Isaias tightens his grip and the economy teeters on the brink of ruin.