President Obama shed tears and soul legend Aretha Franklin gave a surprise performance as Attorney General Eric H. Holder Jr. bid farewell to the Justice Department on Friday after a 39-year career, including the past six as the nation's top lawyer.

During a ceremony to unveil his official portrait, Holder, 64, said he was proud of his accomplishments and praised hundreds of colleagues who turned out to honor him. He was the country's third-longest serving attorney general.

"No attorney general, no AG, has ever loved this institution or you more," said Holder, the first African American to hold the job. Paraphrasing musician Duke Ellington, he added: "I will miss you as I have loved you all: Madly. I love you madly."

Obama wiped away tears as he thanked Holder, who has become a close friend. "With Eric Holder as attorney general, America has become a better country," Obama said. "Which means saying goodbye is bittersweet. You have done a remarkable job. It's hard to let you go."

Franklin came out at the end to perform "America the Beautiful," and she gave the president a fist-bump as she walked to the podium. Then Obama reached down to grab a step-stool for her so she could reach the microphone.

Holder sought to make civil rights -- including protecting the right to vote and shortening mandatory federal sentences for smaller drug offenses -- a part of his legacy. He is set to be replaced by U.S. Attorney Loretta Lynch, whose nomination by President Obama was approved by a Senate panel Thursday. She is expected to be confirmed by the Senate in the next two weeks.

Holder was a lightning rod on Capitol Hill, as Republicans harshly criticized his handling of a botched gun operation by the Bureau of Alcohol, Tobacco, Firearms and Explosives. The operation, known as Fast and Furious, led to an 18-month congressional investigation leading to Holder becoming the first sitting attorney general voted in contempt by the House of Representatives. Holder’s Justice Department was also criticized for prosecuting more government officials for media leak investigations than all other past administrations combined.

But his relationship with Obama was unique; Holder often appeared to serve the role of addressing racial controversies more directly than Obama, who perhaps felt constrained as the nation's first African American president.

"Make no mistake," Holder said Friday. "We still have unfinished business and work to do. Reform of our criminal justice system must continue. The historic wrongs visited upon our native people must be righted. The widening gap in income inequality must be reversed. In the defense of our nation we must always adhere to the values that define us. And, at all costs ... the right to vote must be protected. That list may seem daunting, but if we are true to who we are as Americans, no problem is too big, no issue insurmountable."

Holder's portrait was painted by artist Simmie Knox, who also painted portraits of Bill and Hillary Clinton and Thurgood Marshall. Pausing to take a look, Obama couldn't resist a slight dig at the man who is more than a decade older than the president.

"It's important to point out that Eric has more gray hair than that," Obama said, pointing to the portrait. "Clearly he posed early in his tenure."