For US military helicopter pilots in Afghanistan, a stint flying in Kandahar province is the closest thing to a soft assignment.

There are fewer attacks and fewer casualties than in the hot-spots of Helmand and Paktika. "We swap out crews in places like Helmand, Tarin Kowt and Bagram and go to Kandahar for a break," says Major MJ Hegar. "While I was on a break, we got shot down."

A convoy of American soldiers had been hit by a roadside bomb. Three were injured and needed to be airlifted back to base. It was July 2009. The search-and-rescue team didn't know it, but they were flying into the first such ambush of the war. From now on, the Taliban would target Medevac crews.

As the chopper landed, a rifle bullet smashed the windscreen and fragmented, hitting Hegar in the arm. They let the special forces medics out and took off to assess the damage, but finding nothing serious enough to compromise the mission, flew back into the fight.

By the time they returned, the enemy had set up a heavy machine gun. Bullets ruptured the helicopter's fuel tanks. The crew managed to get the casualties on board without anyone else being wounded, but only flew two miles before crash landing.

Again, they came under attack. Behind makeshift shields of body armour, they fired back at their assailants, defending the injured soldiers until help arrived. "One of the patients we had was female. She got a little bit hysterical, crying and scared – and I've seen men do that too, because sometimes when the bullets are flying you're faced with your own mortality and you understand that maybe you shouldn't be in combat," remembers Hegar.

"My gunner, who is like a brother to me, turned and said, 'Can you believe her? This is why they shouldn't let women drive convoys.''' It was almost as if he had not noticed that Hegar was a woman too. ''I said, 'Are you serious?' He didn't see me as a woman and thought he was talking to another guy, almost. I was a comrade, a colleague, a warrior."

Major Mary J Hegar wears a Purple Heart and the Distinguished Flying Cross, but as a result of the Pentagon's combat exclusion policy she cannot apply for a range of jobs deemed unsuitable for women. Together with three other female soldiers, from the Marines and the Army Reserves, she is suing the Department of Defence, arguing the rule is unsuitable for counter-insurgency operations, and tries to exclude women from the frontline when the frontline is everywhere and nowhere.

Although she loves serving in the National Guard – "I'm what we call a 'mission hacker'. I'm in it for the adrenaline, not the rank" – Hegar is leaving the armed forces. The position she wants most, as a tactics officer deploying with special forces teams, directing helicopters from the ground, is closed to her.

"People are trying to make it an argument about whether or not women should be in combat,'' she says. "But women are in combat and they've always been in combat, since the American Revolutionary War – the entire history of our country. This policy does not keep women out of combat. All it does is hurt the women who are in combat, without recognising what they're doing or giving them equal opportunities."

ALMOST 15% of the 1.4 million soldiers on active duty with the USA's military are female. Around 280,000 women have been deployed to Iraq or Afghanistan. The lawsuit is supported by the American Civil Liberties Union and the Service Women's Action Network.

Under the current policy, women can be "attached" to all-male units and fight alongside men, but unlike male soldiers they cannot choose to do so long-term. The 46 women in Marine Captain Zoe Bedell's Female Engagement Team went to Afghanistan together. They trained separately from the men, but were sent to infantry units in pairs, meaning they had not met any of their comrades.

"Any time someone new comes into a unit they have to prove themselves. But the scepticism that we faced as women was significantly greater," Bedell says. "If a Marine meets a man who's bad at his job, it's just that he's bad at it. If a Marine meets a woman who's bad at her job, it's like all women ever are incapable."

Respect was grudging and hard won: "I assure you the Taliban did not look at the unit and say 'there's women there, let's not go after them.' When you're under attack everyone's fighting back. You're all shooting, all responding the way you've been trained, and women responded very well in those situations."

On patrol, the exclusion policy led to odd compromises and much confusion. "You could not send a woman in to clear a room that might have Taliban in it, so the question is 'Can she be the second person in? The third person in?' We were literally having these debates. 'Does she have wait 30 seconds or 10 minutes?' Silly things like that."

Last year, researchers asked hundreds of officers taking courses at the Army War College what they thought of the policy and concluded that "the current battlefield makes application of the existing rules regarding women and combat unhelpful at least, irrelevant for the most part, and a compromising issue at worst".

A commission set up by Congress recommended that the policy "should be eliminated immediately because, given current practices for employing women in the wars in Iraq and Afghanistan, it seems obsolete". There is still significant resistance within the military. Writing in the Marine Corps Gazette, Sergeant Major David Devaney argued that the infantry places physical and mental demands on soldiers that the vast majority of women are not equipped to handle.

"I have gone as many as six weeks without bathing," he added. "I think this would be a serious problem for women."

Marine Captain Katie Petronio shared her personal experience in the same publication, describing how two tours to Iraq and Afghanistan gradually wore her down, to the point where a compressed spine, muscle atrophy and restless leg syndrome made her incapable of doing her job.

"I am physically not the woman I once was and my views have greatly changed on the possibility of women having successful long careers while serving in the infantry," she wrote. "Should the Marine Corps attempt to fully integrate women into the infantry, we as an institution are going to experience a colossal increase in crippling and career-ending medical conditions for females."

In September, the Marines opened up the Infantry Officer Course to women for the first time, to see if they could withstand the gruelling three-month challenge. Two women volunteered; neither passed. One failed the physical endurance test and the other dropped out injured. One in four men drops out, beaten by the punishing schedule, the lack of sleep and food, or the deliberately disorienting war games. There are no female takers yet for the next course, which begins in spring.

Bedell says: "Keep in mind that you go through this three-month ordeal. It's very physically demanding, you risk injury, and when you come out at the end of it, you're not an infantry officer, because for women this is just an experiment. There's a lot of downside and it's easy to understand why there haven't been a lot of volunteers."

Although the idea of female infantry gets most attention, the exclusion shuts off many other options. Women can fly planes, but not drive tanks. Bedell is a Princeton University graduate. She studied Arabic for three years, learned Farsi and spent a year in Lebanon. "Being an intelligence officer would have been a good choice, because it matches my skills and my background, but that option wasn't open to me," she says. Fed up with being held back, she left the Marines to work for an investment bank.

"People are getting out because they don't feel that their skills are being taken advantage of, but also because of the way that you're treated. It wears you down. It's degrading. It's hard to decide to put up with that when there are options elsewhere."

Confidential surveys have found one in four servicewomen is sexually assaulted by a colleague, but fewer than one in seven attacks are reported. Of those, just 6% result in a court-martial. The Pentagon says there are 19,000 such attacks a year.

"Women will have the opportunity to serve in combat roles relatively quickly," says Bedell. "The other side of it is the - shift to view women as equals, and that'll certainly be longer in coming."

Now legal documents have been filed in San Francisco, the government has two months to decide if it will defend the policy. It is likely the plaintiffs will be called to give evidence. "I see it as my duty," Hegar says. "This is tying the hands of commanders in the field who have well-qualified women that they need to use and can't. We owe it to the military and our country to do this."