It turns out that CBS' Code Black has not flatlined after all.

Though many had put the medical drama on the wrong side of the cancellation bubble, it will return for a Season 3, TVGuide.com has learned. Code Black struggled to find its footing in its freshman season, but rebooted in its sophomore run by dropping half the cast and adding Rob Lowe as a maverick Army surgeon who joins the overworked team of Angels Memorial Hospital.

The show centers on Angels — the busiest emergency room in Los Angeles — and the hospital staff that has to keep the overcrowded medical center running with never enough resources. Marcia Gay Harden also stars as Dr. Leanne Rorish.

Fall TV Scorecard: Which shows are returning? Which aren't?

The renewal comes at the tail end of a busy week for CBS, which canceled comedies 2 Broke Girls and The Great Indoors on Friday and ordered a second helping of its MacGyver reboot. The network also picked up its S.W.A.T. remake series for the fall, starring fan favorite Criminal Minds alum Shemar Moore.

CBS freshman dramas Criminal Minds: Beyond Borders, Pure Genius and Training Day are still waiting to hear their fate, along with The Odd Couple and Ransom.

CBS will unveil its full fall schedule on Wednesday, May 17. In the meantime, keep up with renewals and cancellations from all the major networks here.

(Full disclosure: TVGuide.com is owned by CBS)