Somalia's government has given an amnesty to both the leaders and fighters of the Islamist movement ousted from power last December.
Ethiopian troops are often targeted in Mogadishu
President Abdullahi Yusuf, however, said those with links to "international terrorist" groups were excluded.
The offer is seen as an attempt to persuade members of the Union of Islamic Courts to attend a national reconciliation conference next month.
The Islamists, however, insist that Ethiopian troops leave the country.
"All of them have been pardoned. Leaders and others, officers and those who took up arms or those who supported them financially have been pardoned," said Justice Minister Hasan Bedel Warsame.
Meanwhile, violence continues in the capital, Mogadishu.
A lone gunman tried to assassinate presidential spokesman Hussein Mohamoud Mohamud, Ugandan peacekeepers say.
He sustained a neck injury but has been transferred to Nairobi, where he has left hospital, said Ugandan commander Peter Elwelu.
There have been several assassination attempts on leading government officials.
Mr Ahmed welcomed the amnesty but still refuses to attend talks
In north Mogadishu, gunmen attacked a police station, killing an officer, while in the central Bakara market, two security officials were shot dead by masked gunmen, police say.
Both Islamists and members of Mogadishu's dominant Hawiye clan are believed to be behind the violence.
They strongly oppose the presence of Ethiopian troops, who helped oust the UIC.
UIC leader Sheikh Sharif Sheikh Ahmed has welcomed the amnesty but still refuses to attend the talks, which were postponed from last week.
He said they must be held in an independent location, and not run by the government.
The US has urged the government to hold talks with Mr Ahmed, seen as a moderate Islamist.
The UIC has always denied reports that it has links to al-Qaeda militants.
Some 1,600 Ugandan troops are in Mogadishu, the first contingent of a proposed 8,000-strong AU force, intended to replace the Ethiopians.
Somalia has been without a functioning government since 1991.