The junior doctor, who trained as a doctor in the UK and is not a UK passport holder, was initially detained at Edinburgh Airport in a cell on Tuesday by the UK Border force due to visa issues.
The doctor, who wishes to remain anonymous, was released at midnight and is currently staying with family nearby.
However, much to the concern of his family and friends, he still faces deportation from Scotland this weekend after he was meant to start a placement at a Scottish health board.
Recruited by NHS Scotland, the doctor was expecting to be issued with a visa to work in the country, however, he is still yet to receive this.
He was interviewed for a junior doctor role in Scotland earlier this year and got the job.
Wanting to get a few things in order before he started his new job on Tuesday, he came to the border a few weeks ago and had a discussion with the UK border force about his situation.
The Borders Force then gave him a 6-month visitor’s visa to use until he started working.
Assuming everything was okay with the visa process, the junior doctor then went on holiday abroad with friends last week.
Dr Lewis Thomas Hughes, a fellow junior doctor in Scotland who went on holiday with his friend who faces deportation said: “Before we departed, there was a visa check and there was no issue at all. He had his passport stamped so it is there.
“However, we came back yesterday and then totally unexpectedly my friend had his phone taken off him, had his passport taken off him, was put into a cell, didn’t have access to legal advice and then was issued with a paper notice which said they were revoking his right to remain and we are going to deport you.
"It was same airport we came through (Edinburgh airport) when we returned but completely different interpretation of the application from the Borders Force.”
The junior doctor was told by UK Borders Force he would be sent back to his ‘last port of call’ on Saturday. He could appeal, however, he was told this process takes a long time and it may be too late.
Dr Hughes said: "It all seemed very unusual given there was this understanding but they [UK Borders Force] then said the concern was that he was going to work even though his employers made it very clear he could not.
"They asked if he intends to work here and he said, ‘Not until I have my visa but I will be working ultimately when that comes through’ and they basically said to him, “Well, if you just said you were visiting family we would have let you through’ but he’s a doctor, he can’t be dishonest.
"The fact he’s been honest and he’s landed in this situation seems perverse.
"It seems like someone doesn’t understand or hasn’t read back the checks that have been done by their colleagues [at UK Borders Force].
"It just doesn’t seem like a good outcome for anyone; for him as an individual, for the employer, for patients who are short on other doctors and the UK health service which really needs people to come over here and work. It’s a really bad look.
"The fact that this has happened to a professional who has done all of his training here and has been offered a job here is beggar’s belief- it just doesn’t make sense."
Dr Hughes said he was concerned about a potential “human error” on the part of the Home Office can be so “wild and varied” which is a recurring issue.
The British Medical Association know of similar cases where doctors, who have been offered jobs in the UK, have encountered visa problems.
The BMA has called on both the UK and Scottish governments to fix this issue as they commented they are looking into the specifics of this case.
Dr Lewis Morrison, chair of BMA Scotland, said: “It is usually not advisable to generalise from individual cases, however given the current staffing pressures in our NHS, we need all the doctors we can get and so it is frustrating that some international doctors, who have secured jobs here – and in some cases trained here too – may be having avoidable visa problems.
"We must not lose out on the invaluable contribution these doctors make to the workforce.
“We shouldn’t be in this position in the first place and the substantive solutions lie in the hands of government.”
The junior doctor is now worried that if he has on his record he was refused entry, it will make it “extremely difficult” to get back into Scotland.
Talking about the reason for the visa delay, Dr Hughes said: “I don’t know if it’s because (NHS Scotland) hasn’t applied but it might be a significant Home Office delay.”
Asked about how his friend is feeling, Dr Hughes said: “He feels ashamed which is a horrible thing to feel. He feels as if he has done something wrong and he feels really unwelcome.
"Despite it all, he really wants to get back to work here. I’m not sure that’s the response I would have. He isn’t here because he has no other choice, he wants to be here.”
Dr Hughes said situations like this are a “bad advert” for Scotland for doctors from other countries hoping to come to Scotland.
The “ideal outcome”, according to Dr Hughes, is that the Home Office remove any record of the junior doctor intending to work without a visa and to ensure he is able to “legally” be in Scotland through visa approval.
"This needs to be recognised for the mistake that is was and for it to disappear so he can get to work and see patients.”
The junior doctor is currently meant to be on placement with a health board in Scotland yet the board has said they have no involvement with his employment.
According to the health board, the doctor’s visa sponsorship does not lie with them but NHS Education for Scotland (NES), an education and training body with NHS Scotland who recruited the doctor.
On the staff shortages impacting NHS Scotland, Dr Hughes said: “Even having one doctor off you really feel it. We already do the job of two doctors in the UK so to use one person has a huge influence on the team and patients.”
Christine Jardine, Scottish Liberal Democrat MP said: "This makes our immigration system look like a complete joke.
"At a time when we need skilled medical professionals, it's ridiculous that the individual in question is being treated like a criminal.
"The health board need to take some responsibility for not sorting the correct paperwork but ultimately all of those involved need to show some common sense and help him to get to work as soon as possible."
The junior doctor is currently receiving legal advice and hopes to appeal the deportation.
The NES said it has been involved with the junior doctor’s sponsorship which has been processed.
According to the body, the junior doctor was offered a postponed start until his paperwork was complete.
A spokesperson for NHS Education for Scotland said: "This is clearly a distressing case and our sympathies are with this person. We cannot go into the specifics of an individual case, but we have contacted the UK Home Office and the individual as a matter of urgency to see what we can do to support them.
"We support trainees with sponsorships, but the granting of visas is done by the UK Home Office."
The UK Home Office said the junior doctor has not applied for a work visa but added they are welcome to submit a visa application and “return once it has been processed”.
Individuals without the necessary immigration permission for the activities they intend to undertake in the UK “may be refused permission to enter at the border”, according to the Home Office. A Home Office spokesperson said: “We welcome all doctors and medical professionals who wish to come to work within the NHS.
“Everyone entering the UK to work, regardless of where they enter from, is required to have a valid work visa.”