They had trained together for three years in the military and were deployed overseas side by side. In June, they arrived in Iraq, where they worked as a team scouring houses and villages for hidden explosives. Then, one afternoon, riding back from a mission, a roadside bomb went off under their Humvee.

Air Force Tech. Sgt. Jamie Dana was critically injured -- bleeding internally, her lungs collapsed, her spine fractured, her pelvis broken. In her last moment of consciousness, she asked in desperation about her comrade. "Where's Rex?" she pleaded. When no one answered, she grabbed a medic's arm. "Where's my dog? Is he dead?"

The medic told her that he was. "I felt like my heart broke," she recalled. "It's the last thing I remember."

Weeks passed before Dana would understand that the medic was mistaken and that Rex was alive. The German shepherd was burned slightly on his nose while Dana teetered at life's edge, doctors unable to assure her family that she would survive.

Not long after she started to rally from her injuries, Dana asked Air Force leaders if she could adopt Rex. The answer was no; it was against the rules, and Rex was still valuable to the military. Now, the Air Force has changed its view -- but federal law stands in the way.

Under Title 10, U.S. Code 2583, the Air Force says it cannot allow the wounded airman to take her combat dog home until the animal is too old to be useful. Rex, 80 pounds and brown and black with gold markings, is just 5 years old, not nearly the retirement age of 10 to 14.

It will take an act of Congress to pave the way for Rex to stay with Dana, 26. For the time being, he is with her on leave and will return with her this week to Peterson Air Force Base in Colorado, where Dana is stationed. Walking with a cane because of nerve damage in her legs and feet, Dana expects to take a desk job while military medical boards consider whether she should retire.

"He's my best friend," she said. "I thought he was dead, and I was almost dead, and that made the feeling to be with him a lot stronger."

In Congress, several lawmakers have taken up her cause, including Rep. John P. Murtha (D-Pa.), who is working to attach to a Defense appropriations bill a provision that would allow Rex's adoption. The measure is expected to emerge from a conference committee by the middle of next month and must face votes in both houses.

"This young lady came as close to death as you can come and still be alive," said Rep. John E. Peterson (R-Pa.), who lobbied on her behalf. "She was extremely seriously wounded . . . and I think a person who came that close to death deserves to have the dog who went through it with them. . . . I think that's the least we can do for her."

Air Force officials said support for granting Dana's request has grown in recent weeks. "You add things up, and this is the right thing to do," said Brig. Gen. Robert Holmes, Air Force director of security forces and force protection.

Dana said the Air Force had turned her down twice. Adopting Rex, officials said in an Oct. 21 letter to Peterson, would not be "a legal or advisable use of Air Force assets, in spite of the sentimental value and potential healing effects it might produce."

Rex was a MWD -- military working dog -- the letter said, with "5 to 9 years of good use" left. It noted: "MWDs are worth about $18K out of training. Consequently, Rex is very valuable to both the unit and the Air Force."

About three weeks ago, Dana saw a change of heart, she said, as she prepared to be discharged from Walter Reed Army Medical Center. She was called to the Pentagon, and Gen. T. Michael Moseley hinted that she and Rex might be together again after all. Later that day, she received a phone call with the news that Rex could join her while she was on leave to see her family in Pennsylvania.

"I was shocked," she said, but she tried not to get her hopes up.

Air Force officials said that as family, friends and members of Congress weighed in on Dana's behalf, Moseley, who was to become the Air Force's new chief of staff, took a strong interest. His view, Holmes said, was that "she's a wounded warrior. They went through this together; they need to heal together."

Dana said it was hard to imagine life without Rex.

A friend brought the dog to see her in the hospital as soon as Dana was out of intensive care. When she heard them coming in the hallway, she whistled -- and Rex made a rush for her, leaping into her bed and tangling himself in her intravenous tubes.

"I just wanted to touch him and pet him and feel him and know he was okay," she said.

Before Iraq, Dana and Rex had been deployed to Pakistan for six months in 2004, sharing a tent and together "24-7," Dana said. Although Rex is skilled at detecting explosives, he is not as aggressive as many of his counterparts, she said -- not naturally inclined to "run after someone and grab ahold of him."

Especially in hostile zones, "you want him to be ready to bite someone," she said. "I never knew if my dog would."

Still, Dana said she was happy to have him in Iraq. They were together on Humvee missions, on walking patrols, at night amid the sound of incoming mortars.

The idea of going to war had been hers. "I had begged for it," she said. "I wanted to deploy. . . . You want to feel like you're a part of it, not watching it on TV." She has no second thoughts, even after nearly losing her life. "I just regret I wasn't there longer," she said. Her injury came three weeks into her deployment.

A farm girl from Pennsylvania who joined the military right out of high school, Dana became part of the Air Force police forces eight years ago and later specialized as a bomb-dog handler. Her husband, Michael, is also in the Air Force.

Now, with her life entirely changed, she plans to become a veterinarian -- and she wants Rex to be with her. "I'm waiting to see what happens," she said. It is hard to count on the legislative efforts, "until I have it in writing that he's mine."

By law, the Air Force can't allow Tech. Sgt. Jamie Dana to adopt Rex, her combat dog.

Jamie Dana is joined by her bomb-sniffing German shepherd in Pennsylvania.