When Craig Grossi arrived in Afghanistan's Sangin District by helicopter it was under the cover of night.

When the sun came up, Taliban fighters attacked his unit, and Grossi spent days just trying to stay alive.

"It was a different kind [of fighting] than we'd ever seen," Grossi told The Dodo. "It was pretty fierce for a couple of days, and I was so preoccupied defending myself."

Finally, the fighting subsided and Grossi was able to look around. "We were in a region no [Americans] had been in years," Grossi said. As he looked around he spotted a dog "with a big goofy head and little legs."

Craig Grossi

It wasn't unusual to see dogs. Most dogs were strays who traveled in packs and were often aggressive toward people.

But this dog seemed different.

Craig Grossi

For one thing, he wasn't part of a pack, but was all on his own. He also seemed relatively self-sufficient: He would find little scraps of food and take them to an area of bushes where he'd eat and sleep. On his way, he'd matter-of-factly walk across the marine compound.

"He was as confident as he was little," Grossi remembered. "'He's got it figured out,' I thought."

But the military had a rule for the soldiers not to approach the dogs. "Up until that point I'd never had a problem with the rule," Grossi said.

Grossi watched the dog for a while. "He was no one's dog," Grossi said, "and from what I could tell he had had no real positive human interaction."

Craig Grossi

It soon became clear that Grossi would not be able to follow the rule about not getting close to the dogs. A piece of beef jerky in hand, Grossi made his way over to the dog, remembering to approach carefully.

When Grossi got a little closer, he noticed the dog was really dirty and was covered in bugs. But then the dog did something that totally surprised him, Grossi said: "He wagged his tail and it blew me away."

Craig Grossi

When Grossi offered the dog some beef jerky, "he very politely took it," Grossi said. How could this stray dog, who had no one in the world to care about him, be so good-spirited?

"I gave him a couple scratches behind the ear, and I couldn't believe it," Grossi said. The dog happily accepted the affection.

Craig Grossi

Grossi stood up and started walking away. "I feel a little poke at my angle, I look down, and there he is, following me," Grossi said. Grossi's friend on the other side of the compound shouted across, "Looks like you made a friend," but Grossi heard, "Looks like a 'Fred.'" And that's how this stray dog got his name.

Craig Grossi

This was the beginning of what would become an epic rescue story, but Grossi didn't know it just yet. All of this was happening while he and his unit were in the middle of a war. At night, they would go out to check on civilian families, who were in danger because the Taliban was using them "as human shields," Grossi said. The Taliban used civilian houses for shelters so that they couldn't be targeted.

"When we started going out at night, Fred came with us," Grossi said. But he and the other marines were worried that Fred might bark and draw attention to them. "But Fred figured out not to bark — he never made a sound."

Craig Grossi

"I loved him from the first moment I met him," Grossi said, "but now all the other guys I was with really started to appreciate him."

Craig Grossi

But then it was time to leave. The unit was being called back to the main base, where they would rest for a few days before being deployed somewhere else in the country.

The night before the unit was going to leave, Grossi sat down with Fred to try to figure out what to do. "I was talking to him," Grossi said. "'If you want [to leave],' I said, 'I need a sign.'"

Craig Grossi

The next day the helicopter came. Hovering above the marines, all packed up and ready to leave, it kicked up dust and debris. Grossi was sheltering himself with his group and suddenly he felt a familiar poke at his heel. It was Fred.

"He was terrified but he was there," Grossi said, "and I was like, 'alright, let's go!'"

Fred traveled in a duffel bag among the unit, who were determined to keep his presence on the down low.

"If I got caught with him, I could go to jail," Grossi said. "And he would be put down, no questions asked."

When he arrived at the base, Grossi managed to smuggle Fred unnoticed into a friend's pick-up truck, and as they were driving, Grossi saw a yellow sign with red letters: DHL. "[The shipping company] had set up a station while we were out in the field. It was amazing timing," Grossi said.

Craig Grossi

He went over to the station that night to check it out, being careful to ask, hypothetically, about how he would go about shipping a dog back to the U.S. "'If I had a dog,' I said over and over," Grossi said. "But they saw right through me."

The workers at the DHL station were from all different countries in Africa and Southeast Asia. Many had taken this job because it paid well and allowed them to send money back home to their families.

"Bring the dog," a man named Peter told Grossi. When Fred met the DHL guys, they too fell in love.

Grossi had to go back into the field and he didn't have time to pull together the paperwork to ship Fred back to his parents' house in the U.S. The DHL workers agreed to keep Fred for him while Grossi was gone.

Craig Grossi

But Grossi almost didn't come back.

In the field, this time, Grossi was hit by a rocket and suffered a brain injury. As he was recovering in the hospital, he just kept thinking about Fred.

As soon as he got out, he went straight over to DHL to see Fred, but he didn't spot him and started to worry.

"I look around and I don't see Fred," Grossi said. "But then I see the workers playing soccer and Fred is in the middle, running around with guys from all over the world. It was just this universal moment."

Grossi found a veterinarian who was willing to give Fred a quick exam. He got the forms for Fred's trip ready. And Fred was almost on his way to America.

But there was still a key, missing piece. Fred had no crate to travel in and Grossi couldn't find one anywhere. "I'm like racking my brain trying to figure this out," Grossi remembered.

One day he was at the cafeteria at the base and a marine he didn't know waved to him. "I know about Fred," the marine said. "And I want to help."

The marine happened to be working in the unit that cared for military dogs, and he could easily give Grossi a spare crate. It was perfect.

Fred arrived at JFK Airport in New York City, and Grossi's family drove up from Virginia to retrieve him.

"There were all these things people were sending home on the conveyor belt, like rugs and carpets," Grossi said. "And then there was this filthy dog."

Three months later, Grossi came home to join Fred.

Grossi got a government job for a while, but then decided to go to school. In the summer of 2015, he and Fred traveled the country together for 8 weeks, coast to coast, telling their story to anyone who was interested.

Now that he graduated from Georgetown University in May, Grossi, who used to love writing, has taken it up again and is currently working on a book about Fred's rescue.

"Everywhere we went that summer I told this story in some version and people always loved different parts about it," Grossi said. "I thought that was really cool."