Three people were killed after Al-Shabaab jihadists stormed the SYL hotel near the highly fortified presidential palace compound on March 14, leading to a siege of more than 13 hours.
Security forces also killed five assailants in a gun battle, police said after announcing the situation had been brought under control.
"Following extensive investigation, security forces successfully captured the network responsible for the SYL Hotel terrorist attack, arresting 16 suspects including the mastermind Abdinasir Dahir Nur," Somalia's National Intelligence and Security Agency posted on X late Saturday.
"Justice will be served in court for all involved," it added.
NISA said five members of Somali security agencies who were responsible for the checkpoints the assailants passed through were among those arrested.
The main suspect, Nur, was accused of organizing the vehicles used in the attack, while four others arrested were individuals whose names were used to register the vehicles, it said.
The SYL has been hit by Al-Shabaab several times in the past, and the government has faced criticism over the latest attack because the hotel is in a high-security area.
It is close to the Villa Somalia government complex that includes the presidential palace, the prime minister's office and ministry buildings.
Access to the site is difficult and traffic is also restricted on the road where the hotel is located.
The hotel siege broke a relative lull in attacks by Al-Shabaab militants in the face of a major offensive against them launched in 2022 by government forces and local clan militias.
On Saturday, fighters from the Al-Qaeda-linked group also stormed a military base outside Mogadishu, with casualties reported.
Although the army and militias have retaken territory in central Somalia in the military operation, backed by an African Union force and US air strikes, there have been some setbacks.
Earlier this month, Al-Shabaab claimed that it had taken multiple locations in the region.