A FIVE-year-old girl whose mother faces deportation to Jamaica for dealing in cocaine is to be allowed to stay in Scotland with the woman who has looked after her since she was a baby.

Three appeal court judges conceded there was no ideal solution for Fiona Matthan. She would almost certainly face problems as a black child being brought up in a white environment.

But they upheld the decision of Perth Sheriff John Wheatley that it would be in Fiona's best interests to remain in a stable and loving home with her foster mother, Mrs Helen Osborne, rather than suffer the distress of being sent back to an uncertain future in Jamaica.

Mrs Osborne, of Firbank Road, Perth, raised an action in Perth Sheriff Court seeking custody of Fiona and in April last year the sheriff ruled in her favour. The mother, Miss Althea Matthan, appealed to the Court of Session.

Lord Rodger, the Lord President, said Miss Matthan, 22, was born in Jamaica and came to Britain in about 1991. She lived in a tower block in Hackney where Mrs Osborne also lived.

Miss Matthan began selling drugs from her flat and in April 1994, was threatened by two armed men in her home. She agreed that for her daughter's safety, Fiona should live with Mrs Osborne full-time.

In February 1995, Miss Matthan was arrested for drug dealing and jailed for three years. She was also told she would be deported at the end of her sentence but that process was halted pending the outcome of the custody dispute.

While in prison, she gave birth to Fiona's half-sister, Crystal, whose father was the co-accused in the drugs case. He was sentenced to four years and deported to Jamaica at the conclusion of his sentence.

In the meantime, Mrs Osborne had returned to live in Perth and became Fiona's principal carer. In deciding in Mrs Osborne's favour, Sheriff Wheatley said that Fiona was happy and settled with the Osborne family and there was a strong bond of mutual affection. She was doing well at school and had been a full member of the family since she was 16 months old.

There was an offer of accommodation by a great aunt who owned a large 12-bedroomed house in a pleasant part of Kingston, Jamaica, but the sheriff said he had ''serious reservations'' about Miss Matthan's commitment to the long-term care of her daughter.

The sheriff also said: ''It is agreed that Fiona, who has never been to Jamaica, would suffer considerable distress if she were summarily removed to . . . a wholly alien enviroment.'' He did not think she should be exposed to such ''pain, stress, and uncertainty''.

Miss Matthan's intention on her return was to make contact with Fiona's father who had a criminal record, including two years for shoplifting.

Lord Rodger said the paramount consideration was the welfare of the child and in a case where the sheriff had seen and heard the witnesses it would be unusual for an appeal court to interfere with his judgment on the issue of custody.

However, Mr Colin Campbell QC, for Miss Matthan, argued that there was a ''strong supposition'' that it would be in Fiona's best interests to be brought up by her natural mother.

He also pointed to the expert evidence in the case about the problems Fiona would face as a black child brought up by a white family in an overwhelmingly white community.

The sheriff had acknowledged ''serious potential problems'' in that situation.

Mr Campbell submitted that to leave Fiona in what might be materially more advantageous circumstances in Scotland rather than allowing her to live with her mother and half-sister in Jamaica was indulging in exactly the kind of social engineering which had been condemned by the English courts.

Lord Rodger said the sheriff was entitled to have considerable doubts as to whether Miss Matthan would take up her aunt's offer of support on her return to Jamaica.

She had formed relationships with two men with criminal records and it seemed unlikely she would be content to live with her aunt without contact with men of her own age.

The critical factor was the uncertainty about what would await Fiona in Jamaica. He could see no basis for saying that the sheriff had reached the wrong decision and he had little doubt that Mrs Osborne would take a responsible attitude over the need to maintain contact between Fiona and her mother.

Lords Caplan and Wylie agreed.