The man, Solomon Popoola, who resides in Msida, was also charged with having stolen a Nigerian passport issued to Okoro Mac Zerob Omaka on 21 June.
He pleaded not guilty.
The defence requested bail since the accused was going to apply for refugee status. He had accepted to be held at the Hal-Far Reception Centre under police surveillance, the defence said.
The prosecution did not object to the defence's request.
The court, presided over by Magistrate Dennis Montebello, granted bail to the accused under the conditions set out by the defence. Bail was granted against a personal guarantee of Lm200.
Police Inspector Mario Haber prosecuted, while Dr Richard Sladden assisted the accused.