Rafail Hamidov has been living in Sweden since September 2006 on a temporary residence permit, the Blekinge Läns Tidning (BLT) reports.
Ever since arriving in the country, he has done his best to follow the rules and do what was expected of him.
He started studying Swedish and even managed to find employment as a forestry worker.
Because the job was more than 80 kilometres away from the couple's home in Karlshamn, however, Hamidov choose to spend the work week at the job site rather than spend three hours a day commuting back and forth.
But the decision to commute weekly ended up having dire consequences for Hamidov's bid for a permanent residence permit.
In the eyes of Sweden's Migration Board (Migrationsverket), Hamidov and his Swedish wife were no longer living together, leading the agency to deny his application for permanent residency.
A lack of a permanent residency then led Hamidov's employer to decide not to hire him permanently.
Thus, when the worker Hamidov had temporarily replaced came back to work, the Azerbaijani once again found himself out of job.
A case worker with Sweden's National Public Employment Agency (Arbetsförmedlingen) suggested instead that Hamidov take classes in hopes of increasing his employability.
“I have a university degree in economics from my home country and I've had it approved by Sweden's National Agency for Higher Education (Högskoleverket),” Hamidov told BLT.
“If I add to my credentials I'll increase my chances of getting a job.”
But when Hamidov applied for loans to support himself while studying, the Swedish National Board of Student Aid (CSN) also turned him down because he didn't have permanent residency.
Hamidov and his wife, who are expecting their first child, then sought social welfare in order to scrape together enough money to pay their bills while Hamidov pursued his studies.
But their application to social services was rejected because welfare payments can't be used to help finance education costs.
Ironically, had Hamidov chosen not to take a job which required a weekly commute, he would have received permanent residency, writes BLT.
"The Migration Board, the municipality, and the employment agency all belong to the same country but they all say different things," said Hamidov.
"One authority says ‘work' and another says ‘you're not allowed to work'. What is someone supposed to believe?"
Migration Board spokesperson Louise Utter admitted that sometimes the rules work against even the most well-intentioned immigrants.
“Unfortunately, our laws don't always line up with one another,” she told the newspaper.