If Mr. Hyde says “block,” the dog will stand perpendicularly in front of him to keep other people at a distance. If he asks Mya to “get his back,” the dog will sit facing backward by his side.

The dogs are trained to jolt a soldier from a flashback, dial 911 on a phone and even sense a panic attack before it starts. And, perhaps most important, the veterans’ sense of responsibility, optimism and self-awareness is renewed by caring for the dogs.

The dogs help soldiers understand “what’s happening as it’s happening, what to do about it, and then doing it,” said Joan Esnayra, a geneticist whose research team has received $300,000 from the Defense Department to study the issue. “You can use your dog kind of like a mirror to reflect back your emotional tenor.”

The dog is also often the first visible manifestation of a former soldier’s disability. Because people are curious about the animal, the veteran gets an opportunity to talk about his condition and his war experiences, discussions that can contribute to recovery. More broadly, the dogs help increase public awareness of P.T.S.D., which the Veterans Affairs Department said affects about one quarter of Iraq and Afghanistan veterans with whom it has worked.

Image At the Mid-Orange Correctional Facility in Warwick, N.Y., service dogs share a room with the prisoners who help train them. Credit... Stephen Crowley/The New York Times

Under a bill written by Senator Al Franken, Democrat of Minnesota, veterans with P.T.S.D. will get service dogs as part of a pilot program run by the Department of Veterans Affairs. Training a psychiatric service dog and pairing it with a client costs more than $20,000. The government already helps provide dogs to soldiers who lost their sight or were severely wounded in combat, but had never considered placing dogs for emotional damage.

But there is debate within the emergent field about the appropriate time to pair a veteran with a dog. Sara Meisinger, the chief of occupational therapy at the warrior transition unit at Walter Reed Army Medical Center, said a service dog should be used only in the final stage of treatment, after a soldier has accomplished as much as possible with traditional therapy. Many experts say the veterans should be living on their own for at least a year before they receive a dog.