John Sullivan: Writer who created the classic sitcom 'Only Fools and Horses', as well as 'Citizen Smith' and 'Just Good Friends'

If he had only ever written Only Fools and Horses...John Sullivan would have ensured his place among the creators of classic television sitcoms.

He wrote others, such as Citizen Smith and Just Good Friends, but it was his saga about the Peckham wheeler-dealer Derek "Del Boy" Trotter and his "plonker" younger brother Rodney that caught the imagination of the public – who demanded more and more episodes and specials. Sullivan satisfied that demand for 22 years, then wrote the spin-off series The Green Green Grass and a prequel, Rock & Chips.

It all began early in 1981, when he was chatting to a BBC producer, Ray Butt, about street markets, which he had observed as a child growing up in the south London suburb of Balham. Sullivan's idea was to write a sitcom based around a "wide boy" fly-pitcher, who sold just about everything, without a regular stall.

He turned it into a script with the title Readies, but the BBC had concerns about making comedy out of financial fiddling and tricking customers. Eventually, though, it gave the go-ahead to the series, which began later that year.

Alongside David Jason as the sly but sentimental Derek Trotter and Nicholas Lyndhurst as the gauche Rodney, the original cast featured Lennard Pearce as the seen-it-all Grandad, who lives with them in a south London council flat.

The first two series failed to make much impact, but repeats began to ttract viewers to the warm relationships between the trio and satellite characters such as the "village idiot" road sweeper Trigger (Roger Lloyd Pack) and the snobbish used-car salesperson Boycie (John Challis).

As the sitcom more than doubled its viewing figures in subsequent series, with up to 20 million watching, Sullivan added further characters – the easily conned, long-distance lorry driver Denzil (Paul Barber), the gullible Nag's Head landlord Mike (Kenneth MacDonald), Boycie's wife Marlene (Sue Holderness), Del Boy's girlfriend Raquel (Tessa Peake-Jones) and Rodney's wife-to-be Cassandra (Gwyneth Strong). When Pearce died in 1984, Buster Merryfield was cast in the new role of Uncle Albert.

Sullivan – who also wrote and performed the theme song that was used from the start of the second run – intended the seventh series, in 1991, to be the last, but three Christmas specials (1991, 1992, 1993) followed. Planning to tie up the story of the Trotters, he wrote a three-part eries aired over Christmas 1996, with Del Boy and Rodney's quest for riches finally turning up trumps as they become millionaires.

Nevertheless, the demand for more episodes resulted in three further Christmas specials (2001-03), featuring the brothers after losing their riches in bad investments and a stock market crash. Sullivan then firmly closed the door on the saga, which ended with the late Uncle Albert leaving the brothers a £250,000 fortune.

As well as winning many Bafta Awards and a 1997 Writers' Guild of Great Britain award for Sullivan, and attracting the highest audience for a British sitcom episode – 24.3 million in 1996 – Only Fools and Horses.... was voted best sitcom in a 2004 BBC poll.

Sullivan was born in 1946 in Balham, south London, where his father was a plumber and his mother occasionally worked as a cleaner. An inspirational English teacher gave him a love of literature, particularly the novels of Charles Dickens. However, Sullivan left school at 15 with no qualifications and found jobs as messengers, first for the news agency Reuters, then for the advertising agency Collett Dickenson Pearce.

He moved to a secondhand motor trader, valeting vehicles before becoming a salesman, then took a job at Watney's brewery. He worked there with a school friend, Paul Saunders, with whom he wrote a sitcom script. It was rejected by the BBC, as were his own subsequent solo efforts. Sullivan switched to plumbing but decided that the best way to get a foot in the television door was to find a job at the BBC.

Taken on as a scenery shifter on programmes such as Porridge, he took the opportunity to talk about one of his sitcom ideas to the producer Dennis Main Wilson, who was enthusiastic about the story of the Marxist revolutionary and Tooting Popular Front leader Wolfie Smith trying to emulate his hero, Che Guevara, on the streets of south London.

As a result, Citizen Smith was given a pilot episode in the 1977 Comedy Special slot and quickly turned into its own series (1977-80). The character, whose battle cry was "power to the people", was based on one observed by Sullivan at a pub during the summer of 1968. Robert Lindsay played Wolfie, with Cheryl Hall – the actor's then wife – as his girlfriend and Mike Grady playing his best friend, Ken, who aspired to becoming a Buddhist monk.

At the same time as getting Citizen Smith accepted, Sullivan approached Ronnie Barker with some sketch ideas and was taken on to write for The Two Ronnies. One of his sketches, about the would-be philosophers Sid and George sitting in a bar "talking cobblers", as Sullivan described it, was based on his own father drinking at a servicemen's club, and became a regular item in the show. When Citizen Smith had run its course, Sullivan wrote Over the Moon, about a football club manager. A pilot was made in 1980, but the BBC1 controller, Bill Cotton, decided not to proceed with it because Robert Lindsay was due to star as another sportsman, a boxer, in Seconds Out. Looking for other ideas, Sullivan came up with Only Fools and Horses....

The writer then showed himself to be prolific, creating several other sitcoms. Just Good Friends (1983-86) featured Paul Nicholas as the irresponsible bookie Vince Pinner and Jan Francis as his girlfriend, Penny Warrender, an advertising company secretary.

The comedy came out of Vince's fear of commitment – he had met Penny again five years after leaving her standing at the altar – and the difference in the couple's social backgrounds, his working-class values clashing with her middle-class prissiness. The programme itself was the result of Cheryl Hall previously accusing Sullivan of not writing strong female characters, which he acknowledged.

Then came Dear John... (1986-87), starring Ralph Bates as the wet but well-meaning teacher of the title whose wife leaves him for his best friend. He moves into a bedsit while continuing to pay the mortgage on their house and starts attending the 1-2-1 singles club, where he meets a bunch of assorted misfits. Sullivan based this on his sister's experiences of visiting a divorced and singles club and, although only modestly successful, it was remade for the United States as Dear John USA (1988-92), with Judd Hirsch leading an American cast.

Sitting Pretty (1992-93), with Diane Bull as a jet-setting widow left penniless by her millionaire husband and moving back in with her parents and dowdy sister on a farm, failed to set the world alight, but Sullivan was back on form with the two-part comedy-drama Over Here (1996), featuring Samuel West and Martin Clunes in the story of an RAF Spitfire squadron joined by US Air Force recruits at a British airbase during the Second World War.

Sullivan stuck with the comedy-drama format for the series Roger Roger (pilot 1996, series 1998-2003), with Robert Daws as the owner of a mini-cab firm, then co-wrote, with Steve Glover, another sitcom, Heartburn Hotel (1998-2000), starring Tim Healy and Clive Russell as the chalk-and-cheese rundown hotel owner Harry Springer and schoolteacher Duggie Strachan. Still, Sullivan struggled to emulate his early successes.

The writer re-teamed with David Jason for the four-part Micawber(2001-02), inspired by the character in the Dickens novel David Copperfield. Then, he found further mileage from Only Fools and Horses.... by creating The Green Green Grass(2005-09), four series and three Christmas specials transposing Boycie and Marlene to a rambling Shropshire farmhouse.

He followed this with three one-off episodes of Rock & Chips (2010-11), set in 1960s Peckham, with James Buckley as the teenaged Del Boy and Nicholas Lyndhurst playing a local criminal, Rodney's biological father. The final one will be screened this Thursday.

The relationships between characters were at the core of Sullivan's work, along with an undercurrent of social commentary, and, as the years went by, he lamented the state of comedy writing. "The standard of British comedy has gone down," he said only last year. "Writers make hardly any attempt to tell a story these days. Stuff we had in the past, like One Foot in the Grave and other classic comedies, were far better than anything that's around now."

John Richard Thomas Sullivan, writer: born London 23 December 1946; OBE 2005; married 1974 Sharon Usher (two sons, one daughter); died Surrey 23 April 2011.