CBS has inked a deal to pick up Brett Ratner's one-hour action series Chaos, which was nearly left for dead in June.

According to Variety, CBS and producer 20th Century Fox TV couldn't come to terms on a deal and then options for the show's actors were allowed to expire and both sides called it a day.

Under the agreement, 20th Century Fox TV remains as producer on the show, which is set for a midseason bow. And the show's cast has agreed to come back and continue with the show -- including star Freddy Rodríguez.

CBS initially gave the show an eight-episode order for the hour. Twentieth balked at the offer, as there's not much upside (and no chance of international sales picking up a show) with such a small order.

CBS then offered a 13-episode pickup (including pilot) at a reduced license fee. That was a difficult go for 20th, however, as the studio had already reduced costs on the project.

The humor-laced Chaos stars Rodriguez as a CIA agent who's forced to spy on his colleagues.

Show also stars James Murray, Tim Blake Nelson, Eric Close and Carmen Ejogo.