One of the gunmen was killed and the other was captured in the Wednesday night raid in the town of Yei, the UNHCR said on Thursday.
The gunmen, who broke into the compound, killed one of its Sudanese guards. They also shot a foreigner working for the UNHCR in the stomach and a second local guard in the leg, the statement said.
The staffer and the guard, who were flown to Juba, the main city in southern Sudan, early on Thursday are in critical condition in the local hospital.
The agency plans to fly the wounded to Nairobi, Kenya, for further medical treatment.
"This is a shocking event, and our hearts and thoughts are with the family of the deceased and with critically ill staff members fighting for their lives," the UN High Commissioner for Refugees, Ant?nio Guterres, said in the statement.
"This attack just underscores the difficulties UNHCR faces in our operations in South Sudan where we are trying to create an environment for thousands of refugees in neighbouring countries to be able to return home," Guterres said.
The UNHCR mission in Yei is part of an operation to enable 350,000 refugees to return to southern Sudan from neighbouring countries in the wake of the January 2005 peace treaty that ended a 20-year civil war.