A 25-year-old Iranian asylum seeker who has been on a hunger strike for almost 40 days is near death in a Perth hospital, the ABC has learned.

It is understood Saeed Hassanloo is being treated at Royal Perth Hospital after being transferred from Yongah Hill Immigration Detention Centre on March 10.

He has been refusing food for 37 days, and the ABC has been told doctors fear he will not survive if he does not eat soon.

Mr Hassanloo has been fighting for a visa to stay in Australia since he fled Iran in 2009.

He has been held in detention for the past four-and-a-half years, first in a community detention centre in Melbourne and then at Yongah Hill.

It is understood psychiatric assessments have deemed him sound of mind, and therefore able to decide whether or not he wishes to eat.

That assessment is significant because people have to consent to eat while they are being treated in hospital, unless they are being treated under the Mental Health Act or under the care of a guardian.

A spokesman for the Department of Immigration confirmed an Iranian adult male from Yongah Hill Immigration Detention Centre was being cared for in hospital, however he would not be drawn on specific details of the case.

In a statement, the spokesman said the department was working very closely with medical staff to ensure the man was receiving appropriate care.

"The Government has made it very clear that when a person has exhausted all avenues to remain in Australia, they are expected to depart Australia," the spokesman said.

The psychiatrist who had ultimate responsibility for mental health services in immigration detention until last year, Peter Young, said while hunger strikes were not uncommon among asylum seekers, it was very unusual for someone to refuse food for such a long period.

"Hunger strikes are a type of protest activity that's conducted when people are very desperate and feel as though there are no other ways to express what's going on for them," Dr Young said.

"It would be an awful tragedy if somebody carried out a protest to the extent that they died.

"That is the nature of hunger striking, though.

"They do this because they've run out, generally, of other ways to express what's going on for them."