The Afghan man who set himself on fire at WA's Yongah Hill Immigration Detention Centre is a convicted child sex offender who committed the offences after arriving to Australia as a refugee.

Ali Jafarri was on Tuesday night found barely alive by detainees and Serco guards inside the toilet of his room in the centre's Eagle compound.

Detainees told the ABC he had a blanket wrapped around his body and was completely burned.

It is believed he had doused himself with an accelerant before setting himself on fire.

Emergency services were called to the centre at Northam, 100 kilometres east of Perth, just before 10:00pm on Tuesday.

Jafarri was flown by helicopter to Fiona Stanley Hospital in Perth, where he remains in a critical condition, while two guards who helped him also needed medical care.

Refugee advocates have called for a full investigation into the incident, saying Jafarri had self-harmed before and should have been in a mental health hospital, not a detention centre.

They have also questioned how he was able to get hold of the accelerant.

Jaffari convicted of child pornography, sex offences

Jafarri pleaded guilty last year in the Victorian County Court to one federal charge of accessing child pornography material using a carriage service.

He had been viewing 27 images and videos of teenage boys and girls on his laptop at the St Kilda Public Library between July 2012 and May 2014, when he was arrested by detectives.

He had already had his permanent protection visa cancelled by then-immigration minister Scott Morrison after being previously convicted of six counts of an indecent act with a child.

Those offences occurred after Jaffari was released into the Geelong community on a protection visa, after stints in immigration detention at Christmas Island, Curtin in the Kimberley, and in Perth.

He has been held in immigration detention ever since his visa was cancelled, but could not be deported to Afghanistan because he had been recognised as a refugee.

Detention centre conditions criticised

The union representing immigration detention guards said Tuesday's incident showed the system was not working.

"These incidents shouldn't be occurring in the first place," United Voice assistant state secretary Pat O'Donnell said.

"These detention centres are the responsibility of government. Government are failing to take enough steps to ensure that they're running to the standard the community expects."

A spokesman for Immigration Minister Peter Dutton said the incident would be "thoroughly investigated".

Refugee advocates said Jafarri had felt a complete sense of hopelessness at his situation.

An ambulance leaves the Yongah Hill detention centre. ( Supplied )

"Given that he had been re-detained, it was likely that he was simply facing an indefinite detention, and in those circumstances it seemed likely he had no future and no prospect of release," Refugee Action Coalition spokesman Ian Rintoul said.

"The effects of long-term detention are well-known and this is one of them."

He condemned what he said was a complete lack of suicide prevention programs in immigration detention.

"It's absolutely extraordinary that anyone could find the materials that are necessary to set fire to themselves," Mr Rintoul said.

"But what makes it even more disturbing is that this is not the first time that this detainee had attempted self-harm, and given the circumstances of the last incident I would have thought he would have been under very intensive observation.

"There needs to be a proper and thorough investigation into how this could have happened."

Last month the Refugee Action Coalition called for an inquiry into conditions at the centre, after the sudden death of a 27-year-old Afghan detainee.

Five guards were also injured in a brawl involving up to 50 detainees at the centre in July.