The chaos behind “Chaos” took another unbelievable turn Wednesday: CBS finalized a deal to pick up the Brett Ratner action hour.

Yes, this is the same “Chaos” that was left for dead at the end of June, after the Eye and producer 20th Century Fox TV couldn’t come to terms on a deal.

After that, options for the show’s actors were allowed to expire and both sides called it a day. Hands were wiped.

With “Chaos” dead, CBS even signed a blind script deal with “Chaos” creator Tom Spezialy, who was set to develop a new drama for the network.

But the CAA reps who packaged “Chaos” refused to say die. A new deal was finally hammered out.

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 Rodriguez.

The “Chaos” pickup was chaotic from day one.

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.

Eye and 20th ultimately settled on an episodic order (13) and a license fee that they could live with. But then, CBS and 20th couldn’t see eye-to-eye over budget approval or where “Chaos” might be shot. Eye then pushed to take over full production on the show — a non-starter for 20th.

And then… time ran out.

These days, though, nothing’s ever really dead — just ask the producers of “Damages,” “Futurama” or “Southland.”

In the case of “Chaos,” once talks resumed, calmer heads prevailed and a show that sat six feet under was somehow dug up and nursed back to life.

The humor-laced “Chaos” stars Rodriguez as a CIA agent who’s forced to spy on his colleagues. Ratner, Spezialy and Martha Haight are exec producers on “Chaos.”

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