But his problems were far from over. On February 19, six weeks after his release, he disappeared.
His wife, Sumeyye Yilmaz, says CCTV footage shows him being confronted outside their home after leaving for work and taken by two men before a black van passes by.
Istanbul opposition leader sentenced to nearly 10 years
She fears he is now being held by "deep state" operatives and possibly tortured.
Yilmaz is one of 28 men that rights activists and lawmakers say have been disappeared by security forces since a failed coup in July 2016.
Twenty-five of them have since reappeared -- either they turned up in the custody of the authorities or near a mountain somewhere in Turkey -- but Yilmaz and two others are still missing.
The activists and MPs say that many of the 28 were tortured -- the government says it has a zero-tolerance policy towards torture.
"Why is my partner not being released? What do they want to do? Is he still alive?" Sumeyye, 27, said in an interview with AFP, as their two-year-old daughter played nearby.
"In the first few days he was taken, my daughter would ask 'Where is he?' But now she has stopped. She's a child, she's forgetting," she said, through tears.
Yilmaz, 33, was one of six men who disappeared within a few days of each other in Ankara, Istanbul, the southern city of Antalya and the northwestern province of Edirne in February.
All of them had been accused of ties to a militant organisation run by US-based cleric Fethullah Gulen, whom Ankara claims ordered the 2016 attempted coup.
On July 28, the families were told that four of the missing were being held by Ankara police.
Yilmaz and another man, Gokhan Turkmen, were not among them, which hit Sumeyye particularly hard.
"The period after July 28 was like hell for me," she said.
Both Mustafa and Sumeyye were accused of ties to the Gulen group -- a charge that has seen tens of thousands of people arrested or stripped of their jobs since the coup bid.
The couple denies the claims.
However, Mustafa, a physiotherapist, was arrested last October and sentenced to six years in prison. He was out pending an appeal when he disappeared.
The nightmare began for Sumeyye when she received a call from her husband's employer at around 11:00 am to say he had not shown up for work.
First, she called hospitals, and even at one point feared he could have run off.
But she became suspicious when the authorities showed little interest, and she says the police are still not doing enough to find her husband.
"No effective investigation... or procedure has been started," Sumeyye said, adding it was "still not too late" to find him.
Human Rights Watch says the six men taken in February were "forcibly disappeared" and the four who re-emerged have been denied lawyers.
It said their wives had described them as traumatised.
Lawmaker Omer Faruk Gergerlioglu, of the pro-Kurdish leftist Peoples' Democratic Party who spearheaded a social media campaign to try to find the six, said he believed they had been tortured.
"They were in a wretched state. When the families asked where they had been, the men said: 'Close this issue, leave it alone'," said Gergerlioglu.
Those who took them wanted "to interrogate them for a long time," he added.
The four men have since been formally charged over suspected Gulen links.
"I assume that the goal here is to spread terror" among suspected Gulen supporters, said Ozturk Turkdogan, head of the Turkish Human Rights Association.
"Obviously our main suspect is the state," he added.
Turkdogan said the disappearances often followed a similar pattern, particularly the use of black VW Transporters, according to CCTV images or witnesses.
Contacted by AFP, no comment was provided by the Ankara public prosecutor's office and police, while the interior ministry did not respond to requests.
Cases of missing people have been rare in Turkey since the 1990s, and activists are concerned by the rising number since 2016.
Since the four men's reappearance, another case has come to light.
The family of father-of-three Yusuf Bilge Tunc, 35, have said he was taken by unknown individuals on August 6.
Tunc was accused of Gulen ties -- claims which he denied -- and fired from his job at the state agency overseeing the defence industry.
His family says police claim to have no information on his whereabouts, but that one officer suggested he had runoff.
Turkey coast guard prevent 330 migrants from reaching Greek island: report
"For the sake of argument, let's say that there was a problem between us... why would he not say anything to his parents?" asked Tunc's wife, who did not wish to be named.
"The most painful thing in the world is not knowing what has happened to him."
Like Sumeyye, they have appealed for help from the European Court of Human Rights and the United Nations.
Tunc's wife also claimed police had not bothered to search his car when it was found four days after he went missing.
"I never thought this kind of thing could happen to us," she said.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ