"This was a targeted assassination. We also wounded another MP and two body guards," Shebab spokesman Abdulaziz Abu Musab said.
Witness said MP Ahmed Mohamud Hayd, a former minister and a senior army commander, was killed in the capital's port district, one of the most heavily policed areas in the heart of the city.
Gunmen in a car opened fire on the lawmakers as they left a hotel, spraying bullets at the small group of people.
The Shebab have vowed to intensify attacks during Ramadan.
Also Read
"They were going to attend a parliament session when they have come under attack, one of the lawmakers was confirmed dead," fellow MP Abdi Bare Yusuf told reporters after the attack.
Shebab fighters fled fixed positions in Mogadishu three years ago and have since lost most large towns to a 22,000-strong UN-backed African Union force, fighting alongside government soldiers.
But they still hold sway in vast swathes of the rural hinterland from which they regularly launch guerrilla raids.