Three armed men in military uniform targeted Madeer as he exited the mosque following Friday prayers.
The Islamist militant group al-Shabaab claimed responsibility, vowing to continue attacks against the "infidels" in Parliament.
Madeer is the fifth lawmaker to be killed this year.
Nicholas Kay, the United Nations Special Representative of the Secretary-General for Somalia, condemned the murder and targeting of Somali lawmakers as "an attempt to intimidate and undermine those working to build a better Somalia."
Kay tweeted Friday: "Yet another MP killed in Mogadishu. Sheikh Mader rest in peace. Action against perpetrators needed. Somalia should not let violence win."
Somali Prime Minister Abdiweli Sheikh Ahmed, according to his press office, "urged the security chiefs to do all possible means to bring the perpetrators to justice."
Madeer was chair of Parliament's Finance Committee.