Housing and Urban Development Secretary Dr. Ben Carson has received sharp criticism for referring to slaves who were brought to America as "immigrants" on Monday, but then-President Barack Obama made almost the exact same comparison during a 2015 naturalization ceremony speech.

During remarks to HUD employees on Monday, Carson set off a brief firestorm when he mentioned "immigrants who came in the bottom of slave ships" who had hopes of a better life.

"There were other immigrants who came in the bottom of slave ships, who worked even longer, even harder, for less, but they too had a dream that one day their sons, daughters, grandsons, granddaughters, great grandsons, great granddaughters might pursue prosperity and happiness in this land," Carson said.

Obama made a similar comment during a speech at a Dec. 15, 2015 ceremony for newly naturalized U.S. citizens about the contributions of American immigrants.

Referring to "those of African heritage who had not come here voluntarily," Obama said they were "immigrants themselves" in "their own way" who had faith they could create a better life for themselves.

"And perhaps, like some of you, these new arrivals might have had some moments of doubt, wondering if they had made a mistake in leaving everything and everyone they ever knew behind," he said. "So life in America was not always easy. It wasn't always easy for new immigrants. Certainly it wasn't easy for those of African heritage who had not come here voluntarily, and yet in their own way were immigrants themselves."

"There was discrimination and hardship and poverty," Obama continued. "But, like you, they no doubt found inspiration in all those who had come before them. And they were able to muster faith that, here in America, they might build a better life and give their children something more."

Obama's quote was flagged by Breitbart reporter Charlie Spiering.

Lots of nastiness directed @RealBenCarson – but in 2015 President Obama also referred to the slaves as immigrants https://t.co/0sinrwgQs3 pic.twitter.com/OSzfbrweHb — Charlie Spiering (@charliespiering) March 7, 2017

Carson's remarks drew swift outrage online for conflating slaves taken against their will to America with immigrants coming to the country voluntarily.

"The View" co-host Whoopi Goldberg slammed Carson for the comparison on her show Tuesday. Actor Samuel L. Jackson tweeted his dismay with Carson.

OK!! Ben Carson….I can't! Immigrants ? In the bottom of SLAVE SHIPS??!! MUTHAFUKKA PLEASE!!!#dickheadedtom — Samuel L. Jackson (@SamuelLJackson) March 6, 2017

Other organizations like the NAACP and Anne Frank Center ripped Carson as well.

Carson clarified his remarks later with a written statement explaining that "the slave narrative and immigrant narrative are two entirely different experiences."

"The two experiences should never be intertwined, nor forgotten, as we demand the necessary progress towards an America that's inclusive and provides access to equal opportunity for all," Carson said.