U.S. President Barack Obama has bestowed the nation's highest civilian honor for the last time as president, highlighting the work of Americans ranging from global philanthropists Bill and Melinda Gates to legendary athletes, artists, activists, scientists and others.

Obama presented the Presidential Medal of Freedom to 21 individuals at a White House ceremony Tuesday. Each one, Obama said, had touched him in a personal and powerful way.

Share this video

Microsoft's Gates and his wife were honored for helping to improve and save countless lives in the nation and around the world through the Bill and Melinda Gates Foundation. The foundation focuses on improving health and combating hunger and poverty.

"Few in human history have been more successful than these two impatient optimists," Obama said.

The president also awarded the medal to legendary basketball stars Kareem Abdul-Jabbar and Michael Jordan.

Abdul-Jabbar was hailed not only for his famed basketball career, but for being an outspoken advocate for social justice, the White House said.

Embed code

Copy and paste the embed code below. The code changes based on your selection.

Share this video

Activists, scientists and artists like architect Maya Lin received the award, as well. Lin designed the Vietnam Veterans Memorial.

"The Vietnam Veterans Memorial has changed the way we think about monuments, but also about how we think about sacrifice and patriotism and ourselves," said the president.

Margaret Hamilton received the medal for creating the on-board flight software for NASA's Apollo command modules and lunar modules.

The mathematician and computer scientist started her own software company and co-created software concepts "which set the foundation for modern, ultra-reliable software design and engineering," the White House said.

Comedian and actor Ellen DeGeneres became emotional as Obama draped the medal around her neck. As he did, the announcer read, "In every role she reminds us to be kind to one another and to treat people as each of us wants to be treated."

DeGeneres came out as a lesbian more than 20 years ago, and made history when her TV character came out as a lesbian in 1997.

Since then, the White House said, DeGeneres has become well-known for her humor, humility and optimism.

WATCH: Entire Presidential Medal of Freedom ceremony

The Medal of Freedom was posthumously awarded to Elouise Cobell.

She was a Blackfeet Tribal community leader and an advocate for Native American self-determination and financial independence.

According to the White House, Cobell "used her expertise in accounting to champion a lawsuit that resulted in a historic settlement, restoring tribal homelands to her beloved Blackfeet Nation and many other tribes."

White House spokesman Josh Earnest said Tuesday the recipients were personally selected by the president, adding that "there's no arguing" the recipients are "richly deserving."