Liberal New York City Mayor Bill de Blasio isn’t letting his endorsement of Hillary Clinton stand in the way of his admiration for her socialist rival, Bernie Sanders.

Mr. de Blasio, who stormed into City Hall by decrying the “tale of two cities,” lavished praise on Mr. Sanders and his emphasis on the wealth gap at an event at the CUNY Graduate Center tonight. He credited the Brooklyn-born Vermont senator with pushing the race for the Democratic Party nomination further to the left, even as Mr. Sanders recently embarrassed Ms. Clinton by drubbing her in the New Hampshire primary.

“We’ve got to appreciate what Bernie has done,” he said. “I’ve appreciated Bernie Sanders for decades. But, I’ll tell you, he has helped to energize the discussion of income inequality in this country, and he has helped to push the spectrum.”

The mayor still said he supported the ex-secretary of state and former first lady, asserting she has greater experience and a more detailed approach. But he argued that his party had benefited from Mr. Sanders’ candidacy, and was ultimately “one big happy family.”

“I believe honestly that Hillary Clinton has, in many ways, a stronger platform,” he said. “To all the Bernie Sanders supporters I say, God bless you, because I know you’re doing a lot of good for this country.”

The mayor’s remark came after CUNY Professor Janet Gornick questioned his endorsement of the ex-secretary of state, given that “it seems obvious that Bernie is the superior choice”—a comment that provoked raucous applause from the audience. The other man on the stage, Nobel Prize-winning economist Paul Krugman, gave a far less flattering assessment of Mr. Sanders and his policy proposals.

“Having your heart in the right place is not enough,” he said. “You need to really think hard about the issues, not just go for what feels good.”

In particular, Mr. Krugman attacked the senator for his broadsides against large banks, and instead argued that it was “smaller players” like lender Countrywide that caused the 2008 financial crisis. He also noted that past efforts to push through huge reforms like single-payer healthcare had failed because they asked many politically moderate Americans to make major changes in their personal finances.

“I’m sorry to say, I think that Sanders has to some extent gone for the easy slogan, and Hillary Clinton has been closer to the bone,” he said. “There is a lot to be said for framing your case for change in ways that is conservative in the good sense of the word.”

Mr. de Blasio, however, disagreed—arguing the country was ready for more aggressive action.

“There’s a moment when change is ripe,” he said. “The two leading Democratic candidates are battling each night on who is more progressive, who will be tougher on Wall Street, who will be tougher on the wealthy, who will speak more bluntly about racism and sexism in America. I feel like I’ve died and gone to heaven.”

“You can’t put that genie back in the bottle. Once the discussion has been reset, you can’t go back,” he continued.