Fans of 24 had their world rocked last week when they learned straight-arrow counter-terrorist agent Nina Myers was a mole.

No one had a clue she was a Serbian-speaking double agent named Yelena, hell-bent on assassinating Sen. David Palmer, who's running for president — and trying to prevent her boss, agent Jack Bauer, from stopping it. 

The surprise, 180-degree plot twist has set up tomorrow night's 24 finale as one of the most hotly anticipated of the season. 

But it was not easy to pull off. 

In highly covert fashion — mirroring the show's CIA premise that no one can be trusted  the 24 creative team created a top-secret "policy paper" that explained everything behind the shocking turn. 

"We actually created a document covering every one of those things that actually justifies why she did what she did," said Howard Gordon, one of the show's executive producers. 

"There really is a very good explanation for all of it. We had a few people go through it meticulously." 

Not even Sarah Clarke, who plays Nina, knew about the document. 

But once she learned her character was going to turn out to be the mole  one of the 24 writers had told her well before other cast members found out she did some investigating of her own. 

"I went back, and looked at a lot of the episodes to see how it was tracked," she said. "I started to justify in my head very quickly why I could be ‘it.' " 

Juggling several different story lines and an army of international two-timers, 24 is that rare TV series that has succeeded despite keeping its audience in the dark for most of the year. 

The show, starring Kiefer Sutherland as agent Jack Bauer, has  in late season become a sensation. 

It seemed to take fans more than half the season to discover the series many critics said was the smartest, freshest show of the year. 

24 refers to the fact the show unfolds in real time 24 hour-long episodes that tell the story of an agent's Herculean efforts to save a black Presidential candidate from assassination and rescue his kidnapped family from the Serbian terrorists behind the plot. 

Fans have tended to get carried away by the head-long rush of the story. 

"All my friends were calling, almost as if this was my life," said Clarke, 30. "They were really disappointed in me. They had been so proud and impressed that I could work at the CIA and now, 'How could you do it, you let us all down!' " 

"I had a lot of people come up to me and say, "Oh, I didn't want it to be you, how could you do this to us!" she said. "You feel the remorse, you do!" 

Clarke said that a huge turning point in a plot is never a safe move. "You always run the risk of losing your audience," said Clarke. "The viewer initially tends to be in shock and then needs to be convinced. There's a little adjusting time." 

Clarke was "quite thrilled" with the surprise character shift. 

"It gave me something very specific to play and something very serious to contribute." 

As the countdown to 24's season's finale begins, Clarke  who honed her acting chops in New York repertory theaters and whose film, Emmett's Mark, was recently part of the Tribeca Film Festival here — says she has loved the ride. 

"Last week's episode showed how seamlessly I work in the office leading this double life — speaking Serbian one minute, and then effortlessly saying to my co-worker in English, 'Let's get on with it,' " she said. 

"The finale does a really good job of showing the double nature of the character. You see how Nina was able to pull off what she did."

For more news, entertainment and sports coverage, click here for NYPost.com.