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)

“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)

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.”