A fifteenth century Scottish castle set in 175 acres of land will remain in the hands of the National Trust for Scotland following a failed legal bid by the grandchildren of Brodie of Brodie to have it returned to the family.

The Paris-based Brodies - Alexander Tristan Duff, 31, Phaedra Henrietta Vere, 30, and Edward-Benedict Ninian Annandale, 25, - alleged that the castle had been sold off on the cheap in 1978 and in breach of trust.

At the Court of Session yesterday, however, Lady Smith ruled that the Brodie grandchildren had failed to present relevant arguments to support their claims and dismissed the action, which they conducted themselves.

At one time, Mr Duff slept rough for several nights in a nearby graveyard in protest at a court order banning him from the castle, and the judge said that she understood the grandchildren's emotional attachment to the ancestral family home near Forres.

''I do recognise the upset and distress experienced by the pursuers, by the fact that what they had hoped to be able to regard as their family home is no longer the property of the Brodie family or of the trust from which they may, one day, benefit.

''Given that the sale of the castle occurred about the same time as the break-up of their parents' marriage and a period of evidence, unrest and uncertainty in their own lives, the acuteness of their feelings regarding the castle is readily understandable.''

Lady Smith concluded, however: ''I have no difficulty in reaching the conclusion that they do not aver any relevant case for reduction of the dispositions in favour of the secretary of state for Scotland and the National Trust.''

The Brodie legal saga - family motto Unite - began in 1968 when Montagu Ninian Alexander Brodie of Brodie, now 89 and still living in part of the castle, entered into a trust deed in contemplation of the marriage of Alastair, his son, to Mary-Louise Johnson, the parents of the Brodie grandchildren who brought the legal action.

The trust property included Brodie Castle, but not its contents, which remained the property of Brodie of Brodie.

By 1978 the couple had separated, and the mother settled in Paris with the three children. The father went to live in Australia.

The trustees decided to sell Brodie Castle, which they had power to do under the trust deed, and the Scottish secretary bought the castle and surrounding policies for (pounds) 130,000. The contents of the castle, which included valuable furniture and heirlooms, were sold by Brodie of Brodie to the secretary of state for (pounds) 275,000, a valuation arrived at by Christies.

The Scottish secretary bought the castle with the intention of transferring it to the National Trust, which took over responsibility for its maintenance, preservation and repair, and Brodie of Brodie was allowed to remain in occupation of certain rooms in the castle.

Brodie of Brodie, a former soldier and actor, insisted that (pounds) 130,000 was a fair price for the castle, given its state of disrepair and spiralling maintenance costs.

He also pointed out that his occupation of the castle was ''precarious'', because the National Trust could terminate the arrangement at any time.

The castle has remained National Trust property since 1980, and is open to the public.

In their legal challenge, the Brodie grandchildren asked for the sale of the castle to the Scottish secretary to be set aside and for removal of their grandfather as a trustee.

Lady Smith explained that the basis of their claim was that the castle had been undervalued, that the sale had been in breach of trust, and that their grandfather had received a ''life free rental'' of apartments in the castle.

''Alexander stated that, in essence, the basis of their claim was the loss of a family home, a family home they still required given that the trustees had refused to buy them a house, a family home which they had traumatic memories of having to leave.''