LONDON (AP) _ Mystery writer P.D. James, actor Ian McKellen and romance novelist Barbara Cartland joined a former German prisoner of war on Britain's New Year's honors list Monday for their services to queen and country.

Phyllis Dorothy James, one of the foremost writers of detective fiction, becomes a baroness. She received the only life peerage on this year's list, which is selected by the government.

Miss James, 70, whose latest book is ''Devices and Desires,'' is chairman of the British Arts Council's literature advisory panel and a member of the board of governors of the British Broadcasting Corp. She once worked in forensic science services for the Home Office, which is in charge of law enforcement.

The 51-year-old McKellen, who receives a knighthood, is one of the leading British actors of his generation. Renowned for his Shakespearean roles, he is on tour as the bard's Richard III and as Kent in ''King Lear.''

McKellen, who has also done much to raise money for AIDS charities, said he was ''very surprised and delighted'' with the honor.

Barbara Cartland, 89-year-old doyenne of romantic fiction writers, becomes a dame of the British Empire. Miss Cartland, who has just finished her 530th book, said she was ''delighted and very honored'' to be made a dame.

She said she thought the award probably was not for literary achievement but for the charity work she did.

Her daughter, Raine, became stepmother to Princess Diana when she married Diana's father, Earl Spencer.

Also named a dame is Lucie Rie, 88, a distinguished potter whose work is in the collection of many museums, including the Museum of Modern Art in New York.

Among 28 others to receive knighthoods are Shakespearean scholar and literary critic John Frank Kermode, and Terence English, director of the world-renowned heart transplant research unit at Papworth Hospital in Cambridgeshire.

Among those to receive a Royal Victorian Medal, a personal gift from Queen Elizabeth II, is Walter Gimpel, 64, a former prisoner of war. He works as a gardener in the Crown-owned Great Park in Windsor, 20 miles west of London.

British forces captured Gimpel, then an 18-year-old conscript in the German army, in 1944 after the German retreat from Paris. The medal is an honorary award because Gimpel has retained his German citizenship.

Malcolm Bradbury, novelist and professor of American studies, was awarded the title commander of the British Empire, as was stage and film actor Marius Goring, whose movies include ''The Red Shoes'' and ''The Barefoot Contessa.''

The queen bestowed 995 titles and medals - most of them to people selected by former Prime Minister Margaret Thatcher for the twice yearly expression of gratitude.

The list was drawn up before Mrs. Thatcher's resignation, but the new prime minister, John Major, reviewed it before publication. The other awards are made in June with the queen's birthday list.

It is unusual for there to be only one life peerage, but the new list follows 10 days after Mrs. Thatcher followed custom and submitted an honors list in conjunction with her resignation. Her list included seven life peerages.

Although critics say the ancient honors tradition has been tarnished by political patronage, a barony, a knighthood or a British Empire Medal is still a prize to be treasured. There is no cash reward but to many the rise in status is priceless.

Barons and baronesses are addressed as lords and ladies and can sit in Parliament's unelected House of Lords in the company of Britain's ancient aristocratic families. Knights are addressed as sir, and their female equivalents are dames.

An officer of the Order of the British Empire gets to add OBE after his or her name.