He found her in the middle of the desert in a foreign land, but she got lost in the city while waiting to travel to his home far away.
Heartbroken, he later returned to China to find her, and the moment they were reunited marked a fairy tale ending.
This is the story of Dion Leonard, an Australian extreme marathon runner, and Gobi, a stray dog that followed him during a race in the Gobi Desert in the Xinjiang Uygur autonomous region.
The pair were reunited on Wednesday in the regional capital of Urumqi after volunteers' tireless efforts in searching for Gobi finally paid off.
After the race in June, 41-year-old Leonard decided to take Gobi back to his home in Edinburgh, Scotland. He left her with caregivers in Urumqi until he could raise enough money to take Gobi to Britain.
On Aug 15, Leonard was told in a phone call that Gobi had been missing for a while. Saddened by the news, he flew to Urumqi on Sunday, believing he could find her.
Since his arrival, an increasing number of volunteers had joined him in the search. They walked the streets handing out reward posters and responding to every possible sighting.
On Wednesday, Urumqi resident Ma Liangzhi spotted a dog looking like Gobi in a small restaurant close to where the animal had been cared for.
"I remembered seeing her on the reward posters, so I took her home and called the contact number," Ma said on Thursday.
Ma Ping, a volunteer, received Ma Liangzhi's phone call on Wednesday evening. Although she didn't want to raise Leonard's hopes after all previous sightings ended in disappointment, she still asked him to take a look at the dog.
Gobi was overjoyed to see Leonard, wagging her tail hard and following him everywhere. "It's her," he said.
Ma Ping said: "Gobi jumped around him and wouldn't let him go. Everyone was in tears."
On Thursday morning, Leonard and Gobi went for their first walk together, with Gobi on a leash for the first time.
Mary Peng, CEO and founder of the International Center for Veterinary Services in Beijing who helped Leonard to find Gobi, said: "It's an absolute miracle and a story of love. I think Gobi may have gone off to search for Leonard. With all the people of Urumqi looking for Gobi, they were reunited."