As the riots raged across England on 8 August 2011, Gavin Clarke was fighting for his life after being shot while he exercised in his local park in Chapeltown, Leeds. Clarke, a council worker, father of two and much-loved member of Chapeltown's African-Caribbean community, was sprayed across his face and neck with pellets from a sawn-off shotgun while children played in the streets nearby. He died four days later.

The murder – for which Afzal Arif, 24, of nearby Harehills, was later given a life sentence – brought simmering tensions between African-Caribbean and Asian men to a head. While Clarke lay bleeding, crowds of youths, some wearing balaclavas and armed with bricks, began to gather around the park. BlackBerry Messenger broadcasts circulated: "Shit's kicking off in Chapeltown". Police, acutely aware of the situation in London and Birmingham, positioned riot officers outside Asian supermarkets and mosques.

"Leeds is a fairly small place; Chapeltown is even smaller. It was definitely known who shot Gavin," said Andrew Saddler, a close friend of Clarke's. "If Asian men were found that night … I don't think battle is the right word. It would have been a slaughtering."

Chapeltown, with its history of unrest and poor police-community relations, appeared a prime candidate to join the list of riot hotspots. "There was a lot of things building up," said Lutel James, chairman of Chapeltown youth development centre (CYDC). "A lack of opportunities for young people; the community feeling at times like it's a forgotten community. The death of [Clarke] was a big thing that fuelled the fire, but there was also a sense of frustration."

And yet, despite two nights of skirmishes – the second culminating in the offices of Leeds Caribbean carnival being torched and vandalism against local mosques – full-scale riots were averted. While neighbouring Manchester suffered £6m of damage, Leeds remained untouched. Twenty-one people were arrested during the unrest in Chapeltown, compared with 56 in Huddersfield. There were two convictions: one male found guilty of robbing a takeaway driver, and one female who received a caution for handling stolen goods.

Why didn't Chapeltown riot? A key factor, according to all sides, was West Yorkshire police's decision to allow community workers to conduct some urgent outreach work on the night of the murder, dissuading potential rioters. The decision was prompted by a visit by James and Claude Hendrickson, founder of the Chapeltown young people's club, to the local police station.

"They were going to input the full force of West Yorkshire police on Chapeltown that night," Hendrickson recalled. "But me and Lutel asked them whether we could have one hour to go down and quell the situation. An officer made a very brave decision to hold back the police: on our wishes, she gave us the chance to go into Chapeltown and speak to these young people."

Tensions were still high: wheelie bins were set on fire, a police van was attacked with bricks, a female officer was injured, and a police dog bit a 14-year-old boy. But thanks in part to community workers talking to hundreds of people in the streets and persuading them to go home, the situation was contained.

Vicky Fuggles, of Leeds Youth Services, attended meetings throughout the disturbances, working with young people to explain the police action, keeping youth centres open late, and supporting volunteers. She agreed that this local style of partnership working was crucial to prevent riots.

"If anyone had decided to go off and do their own thing, that would have made the whole thing fall down. I genuinely think it's about the stuff that we do every day."

The deputy council leader, Peter Gruen, said one agency working alone would not have made the difference. "The difference was that the police listened, and changed what was originally a confrontational approach to a neighbourhood supporting role. That was decisive."

The council leader, Keith Wakefield, warned against coming up with simplistic answers as to why riots didn't happen. Geography was important, he said: although the population of Leeds tops 800,000, the inner-city is small, with neighbourhoods generally self-contained and populations less fragmented and transient. "If you are saying that black and Asian people feel a part of the Leeds tapestry, that is broadly speaking right."

There are also historical reasons why Chapeltown did not riot. Like Toxteth and Tottenham, this predominantly African-Caribbean area had been at the centre of the riots in the 1980s. But while many grievances remained, lessons from those earlier riots appear to have been learned.

Sir Norman Bettison, chief constable of West Yorkshire police, is credited with pioneering the use of neighbourhood policing teams, and Chapeltown police have invested heavily in improving relations with community mediators such as James and Hendrickson.

"Culturally in the Afro-Caribbean community there's a big mistrust," said Matt Davison, a neighbourhood police inspector for the suburb of Chapel Allerton. "It's very frustrating. Overcoming that is the first step. The key was to engage the mediators. You need to find someone who can bridge the gap. I would go so far as to say it would be impossible without people like Lutel and Claude."

Tristan Gatewood, 17, admits he was tempted to go out on to the streets last August. Clarke was his godfather and cousin, and he had been devastated at the loss. But those instincts were outweighed, he said, by his commitment to CYDC, which was founded by James – a former professional footballer – in 2002 and is now staffed by more than 100 volunteers.

"I care about football, and I could get somewhere with it if I keep on trying," Gatewood said. "But being out on the street and getting locked up don't make it any better. CYDC means a lot: if it wasn't for this club I don't know where I would be. It more or less keeps you off the streets."

Aqib Hussain, 17, said the influence of CYDC volunteers had kept many at home. "Everyone respects him [James] – the blacks, the whites, the Asians. He's well-known in the community. When he tells you to do something, you are going to do it."

James and Hendrickson, together with police and youth services, are members of the local gang prevention strategy. Leeds has all the risk factors of criminality and deprivation necessary for gangs to grow, but the strategy has stopped young men from becoming gang members. It is one of a number of local projects targeting at-risk youths. Jon Lund, of Leeds Youth Offending Service, said many of the recommendations made by the government's riots panel were already happening in Leeds.

Like CYDC, Chapeltown's Asian community self-organises to support young people. Anwar Shan, who co-founded the Deen Foundation eight years ago, who was a witness to Clarke's shooting, said it was the work of community leaders and the co-operation of the authorities that had kept the situation in check. "Here was troops of people wanting to go into town. Troops of them, blacks and Asians. They would have looted everything," he said.

Hendrickson said things could easily have been very different. "If we'd had a JD Sports on Chapeltown Road, if we'd had a Nokia shop, if we'd had a Vodafone, they would have been hit. Because young people feel that these shops take all their money."

Interviewees were careful to stress the difficulties the area still faced. According to James, policing on the ground in Chapeltown can at times be "disgusting". He was highly critical of the police dog incident on the night of Clarke's murder, which was referred to the Independent Police Complaints Commission. But in general he praised the police's approach last August: "They actually listened, and let the community lead from the front. That's what resolves those situations: the community stepping up the game."

Ch Insp Mick Hunter was second-in-command of the operation on 8 August. Proud of the way his forces behaved, he plans to frame the operational map of the night for his office wall. "Wind the clock back 10, 15 years, we could have had more prolonged disorder because we wouldn't have had those community contacts," Hunter said. "That kind of dynamic means when the chips are down, you can call each other and say: 'Listen, what are we going to do about this?'"

Hunter deployed about 50 riot officers and vans at tactical positions throughout Chapeltown, but his primary goal was to keep the peace. "The atmosphere was very threatening, and there was a lot of anger. But the last thing we want is to send rows of riot vans out to a place like Chapeltown. It ruins relationships, raises tensions and ruins years and years of good work."

Clearly, the will exists on all sides to improve Chapeltown and repair the damage caused by last August's shooting. However, many interviewees warned that relations between Asian and African-Caribbean youths were now in a bad way again.

The area has been able to maintain police community support officer (PCSO) numbers by pooling budgets, but youth services are suffering from the impact of government cuts. According to James, Chapeltown – and other inner-city areas like it – require genuine commitment from central government. He cannot understand why CYDC should struggle to cover its £17,500 annual running costs.

"You've got an active community who are willing to take responsibility, they just aren't given the tools to do it. It doesn't make sense at times. There's no dedicated and sustained investment." Without this investment, he warned, the consequences could yet be dire. Chapeltown and Leeds may not be so fortunate next time.