President Barack Obama speaks during a news conference with Kenyan President Uhuru Kenyatta at State House, on Saturday, July 25, 2015, in Nairobi, Kenya. Obama nudged African nations Saturday to treat gays and lesbians equally under the law, a position that remains unpopular through much of the continent.  (AP Photo/Evan Vucci)

President Barack Obama speaks during a news conference with Kenyan President Uhuru Kenyatta at State House, on Saturday, July 25, 2015, in Nairobi, Kenya. Obama nudged African nations Saturday to treat gays and lesbians equally under the law, a position that remains unpopular through much of the continent. (AP Photo/Evan Vucci)

President Obama took Kenyan President Uhuru Kenyatta to task over the African countryโ€™s record on gay rights during his first visit to the country as president, while also promising increased action against East African terrorists.

During a joint press conference in Nairobi on July 25, Obama chided Kenyatta over Kenyaโ€™s laws, which punish sex between men with as many as 14 years in prison.

โ€œWhen you start treating people differently not because of any harm they are doing to anybody, but because they are different, thatโ€™s the path whereby freedoms begin to erode,โ€ Obama said, according to CNN. โ€œAnd bad things happen.โ€

Despite many similarities between the U.S. and Kenya, Kenyatta said the countries differ in their acceptance of LGBT individuals.

President Barack Obama, right, offers a toast to Kenyan President Uhuru Kenyatta, left, during a state dinner at State House, on Saturday, July 25, 2015, in Nairobi, Kenya. (AP Photo/Evan Vucci)

President Barack Obama, right, offers a toast to Kenyan President Uhuru Kenyatta, left, during a state dinner at State House, on Saturday, July 25, 2015, in Nairobi, Kenya. (AP Photo/Evan Vucci)

โ€œThe fact of the matter is Kenya and the U.S. share so many values: common love for democracy, entrepreneurship, value for familiesโ€”these are some things that we share,โ€ Kenyatta said. โ€œBut there are some things that we must admit we donโ€™t share. Our culture, our societies donโ€™t accept.โ€

President Barack Obama's step-grandmother Mama Sarah Obama listens to his toast during a state dinner hosted by Kenyan President Uhuru Kenyatta at State House, on Saturday, July 25, 2015, in Nairobi, Kenya. (AP Photo/Evan Vucci)

President Barack Obamaโ€™s step-grandmother Mama Sarah Obama listens to his toast during a state dinner hosted by Kenyan President Uhuru Kenyatta at State House, on Saturday, July 25, 2015, in Nairobi, Kenya. (AP Photo/Evan Vucci)

Meanwhile, Obama promised stronger support for counterterrorism operations in Kenya and Somalia, including funding and training for Kenyan security forces. Kenyatta said his country is a new participant in the war on terror, which he called โ€œan existential fight for us,โ€ according to The Washington Post.

On Friday, Obama was welcomed with a festive state dinner hosted in his honor. At the event, Obama was serenaded in English and Swahili by a popular Kenyan group, and enjoyed a performance by a Nairobi youth orchestra.

In a toast to Obama at the dinner, Kenyatta remarked on a program which decades earlier sought to send newly-independent Kenyans to study in Americaโ€”a group which included Obamaโ€™s father.

โ€œRiding on the wings of history,โ€ Kenyatta described Obama as a president of historic consequence โ€œfor America, for Africa and most importantly for Kenya.โ€