Rudy Giuliani reportedly once went to court as New York City mayor to protect illegal immigrants from being reported to the government – and on several occasions praised and encouraged them to settle in the city.

The decades-old views put Giuliani – one of Donald Trump's top advisers during the presidential race and under consideration for cabinet posts that could give him a hand in U.S. immigration policy – at direct odds with the president-elect, CNN reported Wednesday.

"Some of the hardest-working and most productive people in this city are undocumented aliens," Giuliani said at a June 1994 news conference, The New York Times reported at the time.

"If you come here and you work hard and you happen to be in an undocumented status, you're one of the people who we want in this city. You're somebody that we want to protect, and we want you to get out from under what is often a life of being like a fugitive, which is really unfair."

Two years later, in 1996, Giuliani unsuccessfully sued the federal government over a provision in a welfare law that said any city or state employees could not be prevented from reporting someone's immigration status to the federal Immigration and Naturalization Service, CNN reported.

Around the same time, at a speech at Harvard, Giuliani argued it was the city's constitutional right to "protect the health and well being of our city" by shielding illegal immigrants from the federal government.

Giuliani also told WABC in an interview in 2001 – to which CNN posted a link – that New York City was "quite tolerant of undocumented immigration...."

"I think New York City should not deal with undocumented immigrants in a harsh way. I think they make a big contribution to the life of the city and were much better off being sensible and practical about it," he added.