As an author, he created Rumpole of the Bailey, as a lawyer he repeatedly defended freedom of speech, and as a man he left a much-loved legacy which last night drew heartfelt tributes and praise.

Sir John Mortimer, the writer and barrister, who died yesterday aged 85 after a long illness, was hailed as a "brilliant and distinguished figure" as well as a contradictory one: a socialist who liked to drink champagne, a man of laws and letters who defended both Lady Chatterley's Lover and The Sex Pistols, and a respected knight around whom there was, as one of his friends said, always "a whiff of erudition and scandal".

Mortimer combined his career as a lawyer with a prolific literary output that included dozens of screenplays, stage plays and radio dramas. His most famous creation was Horace Rumpole, the cigar-smoking, wine-loving Old Bailey criminal defence barrister. The Rumpole books were first published in 1978 and were then made into a popular TV series.

"It's hard to think he's gone," said Tony Lacey, his editor at publisher Viking. "At least we're lucky enough to have Rumpole to remind us just how remarkable he was."

Born in 1923, the son of a successful lawyer, Clifford Mortimer, John Mortimer was called to the Bar in 1948, rising early before his legal work so that he could write.

In his legal career, he famously defended Penguin, the publisher of DH Lawrence's Lady Chatterley's Lover against obscenity charges in the 1960s; represented the radical magazine Oz at an obscenity trial; defended Gay News magazine against a blasphemy charge, while also becoming an unlikely hero to the punk movement by successfully arguing that the word "bollocks" - used in the title of the Sex Pistols debut album - was an old Anglo-Saxon word and therefore not obscene.

However, despite his life-long left-wing principles, Mortimer's views were idiosyncratic - he supported fox hunting and the monarchy, and once said he believed in every aspect of religion except God.

"No brilliance is required in law," he once said. "Just common sense and relatively clean fingernails."

His family said in a statement: "Sir John Mortimer died peacefully at six o'clock this morning at his home in the Chiltern Hills. His wife and family were at his side."

His 1970 autobiographical play and book, A Voyage Round My Father, was also widely acclaimed - it was later adapted into a television film starring Laurence Olivier - and he was credited with the 1981 television adaptation of Evelyn Waugh's novel Brideshead Revisited.

The curmudgeonly barrister Rumpole - who referred to his wife Hilda as "she who must be obeyed" - was brought to life on television by the late actor Leo McKern.

Mortimer said of the character: "There's a lot of me in Rumpole, although he's much more stoical than I am. He often says the things I think, which is useful because when I say them they sound rather trendy and left-wing, and if he says them they sound crusty and conservative and acceptable."

Mortimer was married twice and had four children, one of whom is actress Emily Mortimer. However, his personal life was not free of controversy. Graham Lord's biography, The Devil's Advocate, revealed that one of Mortimer's affairs, with the actress Wendy Craig, had resulted in the birth of a son, Ross, whom Craig's husband had agreed to bring up as his own.

Last night Catherine Lockerbie, director of the Edinburgh International Book Festival, to which Mortimer was a guest twice in recent years, remembered a man fond of champagne and full of love of life.

"I don't think I can remember meeting anyone with such a zest for life, even though in his last visit he was confined to a wheelchair, he was so energetic and enthusiastic," she said. "The power of his brain was outstanding, his body was weak but his mind was extraordinary, as if the effervescence of the champagne was going directly to his brain.

"He had a piercing intelligence but it was a very human intelligence, not cruel, and the audience loved him."

Broadcaster and writer Melvyn Bragg, a friend and neighbour, said Mortimer had a "wonderful life" that revolved around his cottage in the village of Turville Heath, Buckinghamshire.

Lord Bragg said: "Life was encircled around that place in Turville and he was the monarch of that. We went to pay court to him and, to be honest, you went just to laugh and to hear the latest gossip and the latest book he'd read and what do you think of this and what do you think of that?' "There was a whiff of erudition and scandal always around John and it was completely seductive."

Until his retirement, he divided his time between London and a 40-acre estate in the Chilterns built by his father. But then he and his second wife, Penelope, gave up the London house to live permanently in the country.

Mortimer was appointed CBE in 1986 and was knighted in 1998.

Memorable quotes "When you get to my age, life seems little more than one long march to and from the lavatory." "Liberty is allowing people to do things you disapprove of." "One of my weaknesses is that I like to start the day with a glass of champagne before breakfast." "The shelf life of the modern hardback writer is somewhere between the milk and the yoghurt." "I found criminal clients easy and matrimonial clients hard. Matrimonial clients hate each other so much and use their children to hurt each other in beastly ways. Murderers have usually killed the one person in the world that was bugging them and they're usually quite peaceful and agreeable." "I refuse to spend my life worrying about what I eat. There is no pleasure worth forgoing just for an extra three years in the geriatric ward." "I suppose that writers should, in a way, feel flattered by the censorship laws.

They show a primitive fear and dread at the fearful magic of print." "People will go to endless trouble to divorce one person and then marry someone who is exactly the same, except probably a bit poorer and a bit nastier. I don't think anybody learns anything." "I'd love to be a sex object. My own ambition is to be loved only for my body."