Writer John Mortimer, at the Edinburgh International Book Festival in August 2003. Photograph: Murdo MacLeod/Guardian

The barrister, playwright and author Sir John Mortimer, who has died aged 85, was a man for all the seasons that touched his Chilterns garden, where he lived as profusely as he wrote, in a spirit of unjudgmental generosity. His greatest achievement was to create, in Rumpole of the Bailey, a lawyer whom the world would love.

Though born in Hampstead, north London, John grew up in the house at Turville, near Henley, Oxfordshire, that he never really left. His father was an irascible, blind barrister, the Mortimer of Mortimer on Wills, Probate and Divorce. His mother, devoted and stoic, read aloud the sad, true stories of cruelty and passion between the wars contained in his father's briefs for the divorce court.

John, an only child, was sent to the Dragon school at Oxford, in a class with the historian EP Thompson and a "sour-faced boy who wouldn't share his tuck", who grew up to become a severe circuit judge and model for Rumpole's adversary, Judge Bullingdon. Home from Harrow, the teenager wracked his imagination to stage theatricals that his father might "see" – his contribution to the stiff upper-lipped family pretence that Clifford Mortimer was not blind. In Henley, he encountered with interest the bookshop-owning lesbians who had taken opium with Cocteau, and a prim, elderly lady who had, in her youth, urinated regularly upon pioneering sexologist Havelock Ellis.

He determined to be a writer, and on leaving school joined the Crown Film Unit, devising accounts of industrial and military Britain in wartime. But Clifford had other ideas, a clash captured in A Voyage Round My Father, the account by John of their relationship that first surfaced on BBC radio in 1963: "Father: ... if you were only a writer, who would you rub shoulders with? (with contempt) Other writers? You'll be far better off in the law. Son: I don't know. Father: No brilliance is needed in the law. Nothing but common sense, and relatively clean fingernails. Another thing, if you were a writer, think of your poor, unfortunate wife... Son: What? Father: She'd have you at home every day! In carpet slippers... Drinking tea and stumped for words! You'd be far better off down the tube each morning, and off to the law courts... the law of husband and wife may seem idiotic at first sight but when you get to know it, you'll find it can exercise a vague, medieval charm. Learn a little law, won't you? Just to please me. Son: It was my father's way to offer the law to me – the great stone column of authority which has been dragged by an adulterous, careless, negligent and half-criminal humanity down the ages – as if it were a small mechanical toy which might occupy half an hour on a rainy afternoon."

When Britain's other 1960s playwrights examined their fathers – Peter Nicholls despairingly in Forget-Me-Not Lane, David Mercer bitterly in After Heggarty - A Voyage Round My Father stood out, not only for its stagecraft and for Alec Guinness's central performance, but for the unquestioning love distilled in its lines for this man who had refused to show any to his son. Many young people ruin what would otherwise be talented and useful lives by devoting themselves to law, and John at the time felt himself to be one of them (he was always remarking on the irony of leaving the artificial atmosphere of the court at 4.30pm for the real life of theatre rehearsals). Yet practice of law, although it sapped the early development of his writing skills, eventually gave him the experience which produced his greatest character.

After Brasenose College, Oxford, and at war's end, love and law came hand in hand. He was called to the bar in 1948 and in the following year married Penelope Fletcher, taking on her four existing children and adding two of their own. They wrote a travel book together, With Love and Lizards (1957) and novels separately, as he struggled to develop a practice. Soon he discovered a real talent for divorcing people (in those barbaric, fault-finding days before divorce reform), and for the arcane Chancery world in which time and talent is expended in deciding the validity of a will written on a duck egg, or the charitable status of a legacy to Trappist nuns.

After the series of half-hour radio plays, John adapted A Voyage Round My Father for television (1969, with Mark Dignam and Ian Richardson as father and son), then the stage (1971, with Guinness and Jeremy Brett) and then back into a film for television (1982, with Laurence Olivier and Alan Bates). It returned to the West End stage in 2006 with Derek Jacobi and Dominic Rowan. However, John's first stage success, A Dock Brief – set in the cells, where an incompetent barrister counsels himself and his convicted client – was rooted in his own nervousness about failure and his permanent terror at having responsibility for another's fate. For this reason, he avoided the criminal law until reform dried up his contested divorce work, and he had no alternative but to go "down the Bailey".

By the end of the 1960s he had a considerable reputation as a novelist (his first, Charade, drawing on his Crown Film Unit experience, and unrelated to the movie, appeared in 1947) and playwright, and had played an important role in the abolition of the death penalty and the passage of the Theatres Act, which saw off that bane of the British stage, the Lord Chamberlain's power of censorship – not that his own work had ever been in danger from this quarter.

An irony of his leadership of the anti-censorship movement was his profound belief that anything at all should be capable of being said about sex, coupled with his own reluctance to deal in his work with anything other than its consequence. Sex was an amusing but bemusing fact of life: "The whole business has been overestimated by the poets."

This was not, one feels, an attitude shared by Penelope. Theirs was, in fact, a remarkable marriage, although its final stages were somewhat bitterly reflected by Penelope in her novel The Home (1971). John, typically, celebrated more of the fun and laughter in his play Collaborators (1973), in which the couple metamorphosed into characters played by Glenda Jackson and John Wood.

By this time, John was a successful silk - he had become QC in 1966 - having reinvented himself as an advocate in murder trials. He found a macabre fascination in the pattern of bloodstains, and acquired a singular ability to charm expert prosecution witnesses out of their preconceptions. He was the greatest cross-examiner of such experts ("the art of cross-examination is not to examine crossly") and many alleged murderers owed their liberty to his ability to draw out a doubt in the apparently closed mind.

But nothing in the training of the English bar and bench had equipped it for the underground press, and when, in 1971, a largely unreadable magazine called Oz published a cartoon strip featuring Rupert Bear with an erection, its editors were treated as if they had committed treason. QCs, their cab-rank principles forgotten, fled from the proffered defence brief.

A few days before the trial – for conspiracy to corrupt public morals, an offence carrying a maximum of life imprisonment – Richard Neville and I showed John the offending publication while he was lunching a young woman, also named Penelope. They giggled. We begged him to take the case. "Goody," was his response.

Thus began his second life, as defender of the apparently indefensible, as creator of Rumpole and much else besides, and, from 1972, following his divorce, as husband of Penelope Gollop, Penny the second, and father of Emily and Rosie. His first wife died in 1999. Two autobiographies, Clinging to the Wreckage (1982) and Murderers and Other Friends (1994) speak of a life anchored in family, yet lived in a daily dramatic jumble of court cases, plays and television series, sharply observing the vanities of the world through the blur of diminishing eyesight.

John retired from the bar in 1981. Rumpole was the barrister he wanted to be, but wasn't. He was too nervous – petrified before a big case, and diffident about his own abilities. However, his final speeches, meticulously handwritten, were minor works of literature. Almost alone at the bar, he could laugh a case out of court (had he stayed, he would have made a fortune in libel defences). His forensic contribution to the Oz case was effectively to end censorship for the written word, first for literature, by arguing the appeal which freed Last Exit to Brooklyn (the 1964 novel by American author Hubert Selby Jr that was prosecuted under obscenity laws for its treatment of sex, drugs and violence), then by persuading the jury to reject the moral corruption charge, and going on to demolish, at the appeal, Judge Michael Argyle's directions on obscenity.

Of course pornography corrupted – starting with the policemen charged with enforcing the laws against it, many of whom were later jailed for taking bribes. John put on his wig and took off his glasses, so he could not see some of the trash he was called upon to defend with a success that drew rage from Mary Whitehouse and an extravagant attack from the Times, which claimed that no jury was immune to his charm.

The Williams committee on obscenity, reporting in 1980, agreed with Kenneth Tynan in crediting John with achieving a de facto freedom for the written word by his victorious defence of Inside Linda Lovelace (1973), a shabby little book that would have gone unnoticed had the DPP's office not decided to dignify it with a prosecution, after which it sold a million copies.

From dawn each day John would be at work on his supreme creation, Rumpole of the Bailey. Horace Rumpole had, like all great fictional characters, been composed from fragments of the real people John had worked with, his father, and James Burge (a mercurial Old Bailey junior who never quite recovered from the professional consequences of defending Stephen Ward during the Profumo scandal in 1963) and Jeremy Hutchinson, a mighty defence silk married at the time to Peggy Ashcroft.

In the hands of Leo McKern and Thames Television from 1978 to 1992 (after an initial appearance on the BBC in 1975), and in novels that continued till 2006, Rumpole achieved international acclaim. There are Rumpole societies of lawyers basking undeservedly in his popularity from Los Angeles to Perth. Rumpole is, perhaps, the first truly Dickensian character to emerge from the medium of television. There remains one great virtue about him - his independence - along with much that has, for good reason, passed away. If Rumpole returned today, he would still not be made a silk. The new appointments board displays a marked bias towards appointing prosecutors rather than defenders to the rank of Queens Counsel.

John worked on, long after leaving the bar, meticulous as ever. He came to the European court of human rights in Strasbourg with us in 1995 to research the law and the restaurants that feature in Rumpole and the Rights of Man, and more recent volumes had the bewildered barrister grappling with Asbos and terrorism control orders. Too full of ideas to sleep, he started work on a new film or novel or play – or all at the same time – at 5am, ending in time for long gossipy lunches with friends and family, followed by theatre and parties in London.

In the capital, he has in recent years served as culture's Queen Mother, gracing the National Theatre, the Royal Opera, the Royal Ivy and the Royal Court with his comfortingly unchanging, beaming presence. It is a sorry reflection on his political friends that he was never made Lord Mortimer of Turville, although he was knighted in 1998. Later works included tales of the opportunist Thatcherite politician Leslie Titmuss, Paradise Postponed (1985, televised 1986) and Titmuss Regained (1990, televised 1991); Summer's Lease (1988, televised 1989), set in Tuscany, and Dunster (1992), about an adversarial friendship that culminates in a court case. For Covent Garden he translated Die Fledermaus (1989), for the RSC, adapted A Christmas Carol (1994), and for OUP he produced The Oxford Book of Villains (1992).

The older he became, the more determined he was to cudgel his mind for any idea that might amuse a reader, while continuing to champion the causes for which he cared – the Howard League for Penal Reform, the Royal Court Theatre, and a holiday home for deprived children that he and Penny helped to establish in Turville.

Politically, his faith in liberal socialism wavered at the end. He had emerged from his one-member Communist cell at Harrow to a postwar Labour party he supported with increasing conviction as the Thatcher years changed Britain for the worse. Once the joker, jotting his contributions to the satirical BBC TV comedy That Was The Week That Was during idle afternoons in court in the early 1960s, he and Penny teamed up with Harold Pinter and Antonia Fraser to found the 20 June group in 1987 – reviled almost as viciously in the Tory press as it was by those on the left who were not invited to join. Although saddened by the 1992 election loss, he was increasingly uncertain about Tony Blair and his talent for turning the Labour into the war party. In 2005 he broke the habit of a lifetime, and voted Liberal Democrat.

The previous year an unauthorised biography by Graham Lord produced a delightful result. It stirred some embers, from which emerged, fully-formed, a lost son, the hidden fruit of a 60s affair with the actor Wendy Craig. It was a happy discovery for both men, and later a proper biography, A Voyage Round John Mortimer (2007), by Valerie Grove did her subject justice, capturing some of the pleasures of the Mortimer caravanserai: the long Sunday lunches at Turville in winter, the bluebell picnics in Chiltern woods every spring; the summer idylls in that part of Italy he dubbed Chiantishire.

In the last years, age wearied everything except his mind. His rotund face collapsed, his limbs and bladder gave up, bedtime became a ritual of excruciating pain, yet he continued writing and performing, as if for dear life. Mortimer's Miscellany ran for a month at the King's Head, Islington, north London, in 2007. A doctor's warning that the run might kill him only excited him at the prospect of dying like Dickens. He strove to keep his jokes up to date, although (like the law) they lagged by a decade. (Judge comes into court confessing he has left the judgment he is meant to read in his country cottage. "Fax it up, m'lord," says counsel. "Yes it does, rather.")

His final years brought reminders of his permanent contribution to the English stage, with the much praised production of Voyage with Jacobi, followed in 2007-08 by Edward Fox in the double bill of Dock Brief and Edwin, first aired as a radio play in 1982, about a retired judge obsessed by the notion that his friend and neighbour may have been the father of his son. The house in Turville Heath had acquired a conservatory, for Olivier to pot earwigs in the television version of Voyage. Every weekend until his death it became a place of laughter and gossip and gumboots and children, with friends who felt privileged (although they were never made to feel privileged) to inspect the garden and walk in the wood and sip tea and champagne and talk of everything except Michelangelo, with the Renaissance man who had been saved from terminal decadence by his Reformation wife.

Much of his work in the last half of his life, and much of his continuing happiness, was inspired by Penny the second, whose enormous strengths of decency and determination creatively challenged his own vacillation and reluctance to make moral judgments. The result may be seen in his work, and in his family: actress Emily and model Rosie (daughters with Penny II); Radio 4 producer Jeremy and social worker Sally (with Penny I) and law/IT consultant Ross Bentley, his long-lost son.

John Clifford Mortimer, barrister playwright and author, born 21 April 1923; died 16 January 2009