VALLETTA, Malta — Destabilized by a widening investigation into the 2017 murder of Malta’s best-known journalist, the prime minister of the Mediterranean island nation announced on Sunday that he would resign, but not leave office until January, following an uproar over the possible role of close associates in the killing.

The announcement by Prime Minister Joseph Muscat came just a few hours after thousands of protesters gathered in the Maltese capital, Valletta, to demand his immediate resignation. It was the largest in a series of demonstrations in recent days triggered by suspicions that senior officials knew in advance about the plot to kill the journalist, Daphne Caruana Galizia, and later tried to cover it up.

The protesters, chanting “assassins, assassins” and “shame on you,” marched along the ancient capital city’s main shopping street to the courthouse where, on Saturday, a prominent local businessman, Yorgen Fenech, was arraigned on charges of complicity in the murder of the journalist and other crimes related to the killing.