The last time I saw the C.I.A. agent Carrie Mathison, Claire Danes’s compulsive bipolar character in Showtime’s “Homeland,” she was strapped to a hospital table having electroconvulsive therapy as Season 1 ended. The next time I saw her she was waiting in line at an airport that was draped in Lebanese flags, getting ready to board Season 2 and, to be honest, she still looked shocked.

Danes was wearing a bobbed brunette wig, her green eyes contact-lensed brown, but even at 20 paces — and standing behind several large men wielding lights and cameras — it wasn’t hard to pick out her nervous energy and the pale, twitchy triangle of her face in the shifting crowd. To the worldwide millions of addicts of the first season of “Homeland,” Carrie’s strung-out body language has already become a fixture of Sunday-night TV, as recognizable as Tony Soprano’s brooding shoulders; in this scene she was pulling her carry-on behind her, but she still clearly had plenty more emotional baggage.

Appropriately, this being the set of “Homeland,” nothing was quite as it seemed. For a start, we were not in Lebanon but in Israel. A disused terminal at Ben-Gurion International Airport in Tel Aviv was standing in for Beirut, and there were fake Lebanese Arabs everywhere you looked, practicing for their walk-ons. A sign above one set of check-in desks read, “Welcome Home,” but it is not clear to which particular home it refers.

Danes had been filming in Israel for two weeks, and this was the final day before she returned to shoot the rest of the season, for six months, in Charlotte, N.C. In between takes she tended to sit alone, fiddling with her phone — she’s an obsessive player of Words With Friends — and looking just a little tired and brittle. But whether that was Danes, anxious to get back to the States and her husband, Hugh Dancy, or Carrie Mathison fretting about saving the world from Islamic terrorism (and traitorous Sergeant Brody), was hard to say.

This was the second time that “Homeland” filmed in Israel. Danes and crew were here for the first few days of Season 1 as well. The show was developed from the writer Gideon Raff’s Israeli series “Prisoners of War.” And as Alex Gansa, who created and produces the Showtime version with Howard Gordon, said, the idea of shooting on location represented a happy circularity. “We had taken an Israeli show, adapted it for American television on the basis really of reading just the pilot episode, and then taken it back to Israel to be filmed using the same crew that had done the Israeli version,” he told me. It’s a nice piece of reciprocity, and it’s proven to be an effective way of bringing a heavy dose of reality to a series that has thrown light on the war on terror in ways that few things on TV have.

In Israel, “there was a chaos and energy and feeling that anything could happen at any moment, which you are not going to get shooting in Charlotte,” Gansa said.

“We were just praying that Israel was not going to hit Iran in the middle of filming.”

Danes recalled the stress of filming a few early scenes from Season 1 in a half-Israeli, half-Palestinian town called Barta’a.

“The tension was palpable,” she said, “but I didn’t ever feel particularly threatened.” She had never been to the Middle East and arrived with more curiosity than trepidation. “It has been a lot more fun and cosmopolitan than I had anticipated,” she said, referring to the country as a place in which people “work very hard, worry very hard and play hard and well.”

“The night life is incredibly alive,” she continued, “and there is an extremely positive and generous spirit towards us, quite at odds with what some might have imagined.” Indeed, at the beachfront hotel bar where we were sitting one evening, a couple of people came up to say how much they love Carrie Mathison, how entertaining and important the show is, and how good it was to see Danes back filming here.

The first time around, Danes was more aggressive about seeing the sights. “We went to Jerusalem and Masada and all those absolutely edifying and riveting places,” she said. This time she allowed herself to kick back in Tel Aviv and shop and eat and enjoy the city. “I went to the beach a couple times and to Jaffa, the old port city of Tel Aviv.” She said it was less of a party experience this time, but there has been lots of eating, “gregarious and unabashed eating.” At the time, Danes had not yet announced that she and Dancy are expecting their first child, but it could certainly explain her appetite and the desire to take things easy between takes.

After hours, Danes was smiley and chatty, but some of the nervous energy of Carrie Mathison was still there. After Carrie’s valedictory electroconvulsive therapy in the last episode, I wondered if the character is returning to Season 2 a changed person. A little, Danes said. “She has struggled with some memory loss. Her brain is slightly dulled. But she has achieved some stasis, which had probably become desirable.”

The mania that Danes acted in Carrie, painstakingly researched and played with full abandon, had some in the show’s audience concerned for her own sanity. Gansa later told me they received mail particularly from “people who were bipolar themselves, who were worried that Claire must have it too, to bring it to life so convincingly on camera.” He said that often when you watch an actor play a person with a mental disability, “you feel you are watching Dustin Hoffman playing Rain Man, or Sean Penn playing Sam. But to a large degree, you don’t feel it is Claire playing a role. It is Carrie Mathison.”

Danes takes her responsibility to her character’s condition seriously; but as an actress, she suggested, mania is also an exhausting kind of fun. I asked if she had had any separation anxiety in the months she had been away from Carrie.

“Well,” she said, “it’s been nice to have a reprieve. I feel I put her in the fridge for a few months, next to the vodka. I was a little nervous about being able to access her straight away again, but no, there she is, right next to the vodka. I like her a lot. She means well and she is kind of a superhero. So it is fun to put my crazy Carrie cape on again.”

Part of the pleasure of “Homeland” is the way it dramatizes the crazy Carrie cape of paranoia that we have all worn at some point in the years since 9/11. “Carrie is perceptive,” Danes said, “but her fixation on keeping the world safe is so intense that it overrides that. She also has to be so vigilant in maintaining her own well-being. She has a bomb ticking inside of her that she is always monitoring.”

Danes is gratified that people who live these dilemmas for real are fans of the show. She stays in touch with the female C.I.A. agent — “my big sister” — whom she shadowed while researching the role and who gave her insight into the special difficulty of a woman working in the Middle East with male suspects. It is, Danes said, both “fantastic and spooky” that President Obama has expressed enthusiasm for the show.

When I spoke to Danes’s British co-star Damian Lewis later, he suggested that the legitimacy of “Homeland” comes from its insistence that “war is always fought by the families back home, as well as by the soldiers on the front line,” and from its refusal to draw easy parallels between Islam and violence. “I wouldn’t have done it if that were the case,” he said. “But Brody acts more for personal reasons, a vigilante rather than a jihadist. I think it is a more subversive message to send that a young Marine could find something in the beautiful and poetic and positive forces of this religion, rather than simply being brainwashed by it.”

Mostly, though, Lewis believes the series stands or falls on his character’s riddling relationship with Carrie Mathison. “Thank God Claire is playing that role,” he said. “There is a lot of complex and nuanced stuff to do, revolving around the fact that whenever they see each other, you are not sure if they want to sleep with each other or kill each other. And I love playing it with her because she is just so good at it, so committed to it.”

Gansa said that the minute he and his co-developer, Howard Gordon, settled on the idea of a female C.I.A. agent, Claire Danes was the name that popped into their heads (so much so that they called the character Claire in their first draft of the script). Gansa and Gordon had recently seen Danes’s extraordinary portrayal of the autistic savant Temple Grandin in HBO’s Emmy-winning biopic, and they had followed her career for years. “We had known Claire as an actress since way back in her teenage years and ‘My So-Called Life,’ ” Gansa said. “She’s always had this capacity.”

After she played Grandin in 2009, Danes didn’t work for nearly two years, partly because she felt there were not many good movies being made — “it is rocky out there,” she said — but also because playing the one-of-a-kind doctor of animal science properly stretched her and “I didn’t want to go back to ingénues. Because I ingénued the hell out of it for a while.” Danes had long resisted the typecasting that had been suggested by her early defining role opposite Leonardo DiCaprio in Baz Luhrmann’s “Romeo and Juliet” when she was 16. It was more important for her to wait for the right offer and spend some time with her husband — she and Dancy married in 2009. She signed up for “Homeland” for a possible seven years, because to her “the writing guarantees real quality. I’d been changed by watching ‘The Wire’ and I wanted to do something that had that scope.”

The certainty of the work also allows her a measure of balance between home and “Homeland,” a compromise that no doubt will be more complicated in the coming years. Danes said she has had good mentors in that regard, particularly Jodie Foster and Meryl Streep, with whom she worked on “Home for the Holidays” and “The Hours,” respectively. “I admired them as much for the way they lived as for their thrilling careers,” she said. “They have rich lives and families. They are in the world. Not bonkers — that’s a massive achievement. I would rather not work than be a neurotic mess.”

She first proved this point to herself when she gave up her career for two years and took herself off to Yale University to study psychology, not long after playing Juliet. The idea of being “imprisoned by fame” frightens her, she says. When she became involved in 2003 with her co-star in the film “Stage Beauty,” Billy Crudup — who left his girlfriend Mary-Louise Parker, who was seven months pregnant — the tabloids branded her a home wrecker. These days she says her life is “too predictable” to make headlines. “I cannot imagine what it would be like to be Angelina Jolie or Jennifer Aniston,” she said. “I was watching a documentary about Britney Spears, and what she has to cope with really shook me.”

Marriage, Danes suggested, has been a liberation. “That huge need has been satisfied.” She and Dancy live in New York and have a place in Notting Hill, London, and she relishes the contrast. Sitting next to the sea in Israel, I asked her about her sense of the difficulties of having a family while she and her husband both pursue their acting careers (questions that were more pressing than I realized then). “We would like to have kids at some point,” she said. “We will have to figure out how to do that. I went to high school and acted at the same time. So I do have some experience of doing two things simultaneously.”

In the meantime she has another long-term dependent to take care of: “crazy Carrie.” She likes the idea of the two of them growing older together. “I do get more pleasure from this than almost anything else,” she said, referring to her acting life. “I love words. It is physical. It is intellectual. It’s psychological.” She paused, finished her drink, smiled in her sudden way. “It’s like, I get both to ice skate and fly a trapeze, and who wouldn’t want to do that?”

A version of this article appears in print on September 23, 2012, on page M298 of T Magazine with the headline: Going Rogue. Today's Paper|Subscribe