Craig Grossi knew the risks.

A Marine deployed to a remote part of Afghanistan, Grossi was well aware that he shouldn’t befriend the short-legged, white-furred, innately well-behaved dog. For safety reasons, Marines are warned against buddying up to animals; if caught, the pup could be put down.

Grossi knew the rules. But still, he approached the canine – an unusual loner without a pack – with a stick of beef jerky in his hand. And the dog’s tail wagged.

It was 2010 and Grossi was in the midst of his eight-year stint with the Marine Corps, doing intelligence work in Afghanistan. His new friend, dubbed Fred, became a fast and obedient recruit. He didn’t bark during patrols – except once to alert his troop of danger – silently endured a secret helicopter ride and cozied up to the men in his unit.

Grossi likes to say that that the pair saved each other – and that’s certainly evident. While risking his life to serve his country, Grossi also took professional risks to protect Fred from the war in the Middle Eastern country, arranging to have him sent to his family in the U.S. while he finished his tour.

And for Grossi, while naturally a happy person, the effects of war and career struggles took a toll.

“That’s where Fred came in. Coming home to him every day and his stubborn positivity,” Grossi told Fox News, adding that’s the motto he’s taken. “It’s not a naïve, just smile through whatever you’ve got going on, kind of approach; it’s the opposite. It’s recognizing that there are circumstances in your life that are within your control and ones that aren’t. It’s allowing yourself to focus only on the things you can control.”

“Our adventures and our life and our commitment to stubborn positivity is just beginning.”

The peculiarity of Fred was also evident in how he came to meet the four-legged Afghan. Most dogs in these situations tend to gravitate to where there is people and food, Grossi said. But Fred didn’t come to them; Grossi’s unit “landed on him” in Sangin, he said.

“He hadn’t had any real positive human interaction. He was hot and hungry and covered in bugs,” Grossi said. But still, Fred was friendly.

Now, Fred is bug-free and enjoying the fresh air, cold weather and green foliage of Maine. He’s also the star of his own Instagram account with more than 43,000 followers.

Grossi turned his unique relationship with Fred into a book.

“Craig & Fred: A Marine, A Stray Dog, and How They Rescued Each Other,” recently published by HarperCollins, flips back and forth between the harrowing experiences in Afghanistan and their cross-country travels in 2015.

“Finding the motivation was really about giving myself the permission to write. For me and for other veterans, it’s something we have to overcome in terms of drawing attention to ourselves or doing anything that we might perceive as selfish or self-indulgent,” Grossi said.

“It’s something that I owe to the men and women that I served with and the awesome people that have come into my life. I owe it to them to share this story,” he added. “The story is bigger than me and it’s bigger than Fred.”

So what’s next for the duo?

The book is just the start, Grossi said. The two are still exploring, still finding ways to challenge one another.

“Our adventures and our life and our commitment to stubborn positivity is just beginning.”