He was not an easy dog, not remotely warm or fuzzy.
Rex had been through various handlers, some of whom he had bitten.
“He was everyone’s secondary dog,” said former Marine Cpl. Megan Leavey, who herself had a rocky start with the bomb-sniffing German shepherd when she met him during her time at military police school in Texas.
Sgt. Rex, as he was officially known, bit Leavey at least once.
But Leavey was not fazed, and eventually found herself bonding with Rex, who became her fierce protector. Leavey and Rex – whose bond forms the basis of a movie “Megan Leavey” that will open in theaters Friday, with actress Kate Mara playing the Marine -- went on more than 100 missions together in Iraq between 2003 and 2006.
Rex remained aggressive, even as he learned to be gentle with his favorite human.
“I wouldn’t say I got him to soften up,” Leavey, who is 33, told Fox News. “Our personalities happened to mesh well. He was not soft. He was very protective of me. He was great when he was with me.”
Rex helped spot hidden explosives and was critical in ensuring that paths were clear for troops to travel on. But in one instance, Rex and Leavey were injured by shrapnel in the Ramadi area. The incident left Leavey, who was awarded the Purple Heart, with a brain injury and post-traumatic stress disorder, and her four-legged comrade with an injured shoulder and neurological conditions.
Leavey came back to the United States, where she spent time at Camp Pendleton in California healing and helping Rex through rehabilitation.
“He wasn’t friendly with anyone else,” Leavey said. “It was up to me to make sure he got MRIs done and taking care of other things [regarding his treatment] myself.”
Then it came time to part. Leavey was honorably discharged, but Rex continued on duty, though because of neurological problems stemming from the explosive that hurt him and his Marine partner, his duties were modified.
The separation was heartbreaking for Leavey, for whom the time with the Marines, which she joined during a difficult, aimless period in her own home life, helped anchor her and give her a fresh perspective on life.
But perhaps most of all it was Rex who gave her life a whole new meaning – they helped each other and drew so much from their mutual trust and bond.
“Rex was the one constant in my life,” Leavey said.
Leavey was driven to bring Rex to live with her, but ran into roadblocks.
Rex was the one constant in my life.
She said she is not bitter about those obstacles. She understands that military dogs have an important function and there cannot be an efficient system that gives up dogs when their handlers leave and want to take them back with them.
At one point, Leavey learned that Rex’s health was deteriorating, a situation hastened by his advancing age.
She learned that military medical records categorized him as unadoptable because of his aggression toward some handlers.
That put him at risk of being euthanized, and Leavey could not let that happen, she said. She approached several people in Rockland County, New York, where she lives. Among them was Jerry Donnellan, director of the Rockland County Veterans Service Agency.
“I went into his office and I was crying,” she told the Journal News. “And he was like ‘Wow, this problem has never come up before. This is a first.”
Leavey’s plight caught the attention of Mindy Franklin Levine, whose husband is New York Yankees President Randy Levine, and who is active in many animal rights causes and a strong supporter of veterans.
The Levines reached out to their contacts and pushed for the reunion between Leavey and Rex.
“Her story broke my heart,” Mindy Levine said to Fox News. “She said to me, ‘I’ll do anything to get him back.’ I told her ‘It’s going to be a wild ride,’ but I was very optimistic. I knew she needed this dog to make her complete. I could hear the fear in her voice, of knowing on some level how sick Rex was, perhaps much more ill than we realized at the time.”
Finally, with the Levines and others rallying around Leavey, Rex received approval to be reunited with his Marine. He basked in retirement, loving real dog toys, taking dips in pools, being handed scraps of non-canine food and just lounging around, being pampered.
Her story broke my heart. I knew she needed this dog to make her complete.
“Surprisingly, he took to [civilian life] pretty easy,” Leavey said.
They had only eight months together. Rex died at the end of 2012 at the age of 12.
Earlier that year, Rex and Leavey were honored at Yankee Stadium, where the former Marine was presented with a jersey autographed by the team and then-player Alex Rodriguez gave her a charm engraved with the name “Rex.”
Leavey, who comes from a family of Yankees fans, now is an account executive for the Bronx Bombers, as the team is known, and maintains a close bond with Mindy Levine, who helped get the ball rolling on reuniting the former Marine and her canine partner.
“They were so kind to take care of my travel, to pick up Rex and pay for his medical bills when we got home,” she said of the Levines.
Gabriela Cowperthwaite, the movie’s director, said that above all else, “Megan Leavey” is a movie about “loyalty and friendship, and it's a film about someone who comes to value herself because she begins to value something else, in this case Rex."
"Those are the themes that will hit you at your core," said Cowperthwaite, who usually works on documentaries.
'Megan Leavey' is a movie about loyalty and friendship, and it's a film about someone who comes to value herself because she begins to value something else.
Leavey served as a consultant during the script, and even appears in a scene in the movie, playing a boot-camp drill instructor.
"I'm on cloud nine," Leavey said about having a film about her and the best friend she lost. "It's hard [to relive], but they did a very good job of getting the bonding that Rex and I had."
Elizabeth Llorente is Senior Reporter for FoxNews.com, and can be reached at Elizabeth.Llorente@Foxnews.com. Follow her on Twitter @Liz_Llorente.