US Supreme Court Justice Sonia Sotomayor was among hundreds to bid farewell Thursday to legendary Manhattan DA Robert Morgenthau, who died over the weekend less than two weeks before his 100th birthday.

Sotomayor, speaking at the former DA’s funeral at Temple Emanu-El on the Upper East Side, called her first boss “a treasure” who guided all who worked for him.

“I am living proof of that guidance,” Sotomayor told mourners of Morgenthau, who hired her to be a prosecutor straight out of Yale Law School in 1979.

“Without Morgenthau, I would be neither the person nor the justice I am today,” she said, calling herself “humbled to honor his lifetime of noble work.”

Morgenthau’s casket was draped in an American flag as befitting a World War II naval hero and lifelong patriot.

“We weep, we mourn, we celebrate,” Rabbi Ronald Sobel told those in attendance, calling Morgenthau “incorruptible” and “a legend in the legal profession.”

Sobel spoke of “the thousands — literally thousands — of young assistant district attorneys who lovingly and reverently refer to him as ‘the boss.’

“One of those … now sits on the Supreme Court of the United States,” Sobel said, referring to Sotomayor.

Other dignitaries to attend the service included Mayor Bill de Blasio, former Mayor David Dinkins and former Congressman Charles Rangel.

Morgenthau, who would have celebrated his 100th birthday July 31, was lauded for his unfaltering pursuit of justice, his “steel-trap” memory and his love for his children and grandchildren.

There was also praise for his wry humor.

Lawyer and longtime friend Stephen Kaufman told mourners of the time Morgenthau, as a young naval officer, found himself bobbing in the Mediterranean after his ship was torpedoed.

Another sailor in the water needed help, and “without hesitation, Bob took off his life preserver and gave it to the shouting sailor.”

Asked about the incident years later, “Without hesitation, he replied, ‘I think it was one of the stupidest things I ever did,’ ” Kaufman recalled.

No one in US history has mentored more young lawyers or served longer as a DA — 35 years, Kaufman noted.

Morgenthau, by his own count, oversaw some 3.5 million cases during his years as DA.

He held the post of district attorney of Manhattan from 1975 until his retirement in 2009 and was known for taking down mob kingpins, crooked politicians and killers alike.

Morgenthau’s most notorious cases included John Lennon assassin Mark David Chapman, subway vigilante Bernard Goetz, mob boss John Gotti and “Preppy Killer” Robert Chambers.

In 1961, Morgenthau, a Big Apple native and known to tabloid readers as “Morgy,” was appointed by President John F. Kennedy as US attorney for the Southern District of New York. He served in that role until 1970.

Morgenthau is survived by his Pulitzer Prize-winning journalist wife, Lucinda Franks, and seven children, six grandchildren and three great-grandchildren.

Additional reporting by Laura Italiano