US President Barack Obama has praised Ethiopia for its fight against Somalia-based terror group al-Shabaab during a visit in the East African nation.

Obama, the first US president to visit Ethiopia, said the country's troops help to fight terrorism in Somalia, where thousands have been killed by al-Shabaab terrorists, who carry out attacks in retaliation to the presence of foreign troops in what they claim to be Muslim territories.

Who are the al-Shabaab militants?

Al-Shabaab, which means "The Youth", is a Somali terror group affiliated with al-Qaeda.

An off-shoot of the Islamic Courts Union – a rival administration to the Transitional Federal Government in Somalia – al-Shabaab aims to overthrow the Somali government and impose its own version of Islam in the country.

It controlled Mogadishu and the southern region of Somalia from 2006 until 2011, when it was defeated by African Union peacekeepers.

"Ethiopia faces serious threats, and its contribution to the African Union mission in Somalia has reduced areas under al-Shabaab control," he said during a joint press conference with prime minister Hailemariam Desalegn.

"We've got more work to do. This past week, Ethiopian troops have helped retake two major al-Shabaab strongholds. We have to now keep the pressure on."

Obama also warned that Ethiopia's human rights record needs to improve and the government should stop cracking down on freedom of speech.

"We had a frank discussion," he said. "So we discussed steps that Ethiopia can take to show progress on promoting good governance, protecting human rights, fundamental freedoms, and strengthening democracy."

The two countries are committed to strengthening their relations and cooperating to advance Ethiopian economic development.

Following the conference, Obama was criticised by Ethiopia's opposition groups and journalists after he defined the current government – led by President Mulatu Teshome – as "democratically elected". The opposition accused Teshome and his party People's Revolutionary Democratic Front of intimidating and persecuting people to secure victory in June's parliamentary election, when the party and its allies won 100% of the seats in parliament.

zone 9 bloggers terrorism
Six bloggers part of Zone 9, an Ethiopian blog that focuses on human rights, social justice and corruption, were charged with terrorism earlier in 2015. Two have been released prior to Obama\'s visit to Ethiopia Facebook/Zone9

Ethiopia's freedom of speech

Rights groups have warned that journalists in Ethiopia are imprisoned, sometimes tortured and not guaranteed a fair trial.

According to a March 2015 report by Human Rights Watch (HRW), at least 22 journalists, bloggers, and publishers have been criminally charged and at least six publications have closed in Ethiopia amid a campaign of harassment in 2014.

"Ethiopia's government has over the past year intensified its assault on media freedom by systematically trying to silence journalists," said Cynthia Wong, senior internet researcher at Human Rights Watch. "These digital attacks threaten journalists' ability to protect the safety of their sources and to avoid retaliation."

The HRW report came a few weeks after the Ethiopian Federal High Court charged six bloggers and three independent journalists with terrorism.

The defendants – who are part of Zone 9, a blog that focuses on human rights, social justice and corruption – were arrested in April 2014 and were accused of plotting with the Ginbot 7, a political party classified as a terrorist organisation in Ethiopia.

Hours before Obama's arrival in Ethiopia, two of the six bloggers – Edom Kassaye and Zelalem Kibret – were released. The Committee to Protect Journalists warned that at least 11 journalists are still in jail.

Last September the UN issued a statement urging Ethiopia to stop abusing its laws, which HRW deemed "deeply flawed".