Democratic presidential candidates Hillary Clinton, former Maryland governor Martin O'Malley and Sen. Bernie Sander (I-Vt.) at an earlier debate. (Chuck Burton/AP)

Former Maryland governor Martin O’Malley, who risked not qualifying for the next Democratic debate, will be on stage Sunday night in Charleston, S.C., after all.

NBC News, which is broadcasting the event, announced Thursday that all three Democratic hopefuls have met its polling-based criteria to participate.

That means O’Malley will appear alongside former secretary of state Hillary Clinton and Sen. Bernie Sanders (I-Vt.) in the final debate sanctioned by the Democratic National Committee before the Iowa caucuses Feb. 1 and the New Hampshire primary Feb. 9.

Earlier this month, NBC announced that the debate would be  limited to candidates with an average of 5 percent in national polls or in Iowa, New Hampshire or South Carolina. That put O’Malley, who is running a distant third in the race, right on the cusp.

Upon learning of the NBC criteria, O’Malley accused the network of treating the debate process “as if it’s another episode of ‘The Apprentice,’” the popular NBC show formerly hosted by Donald Trump — now the Republican presidential front-runner — in which contestants are eliminated each week.

NBC is partnering with YouTube on Sunday’s debate, which is hosted by the Congressional Black Caucus and sanctioned by the DNC and the South Carolina Democratic Party.