It's one of the more unlikely-sounding sitcom ideas of recent times. The original pitch for Bluestone 42, BBC3's new comedy, might have been: "The Hurt Locker meets Miranda." This new eight-part series is a comedy about a British Army bomb disposal unit working in Helmand Province, Afghanistan. And yes, you did read that correctly.

Filmed in South Africa, which doubles plausibly for Afghanistan, the sitcom is scripted by Richard Hurst and James Cary, who made their names writing on BBC1's hugely popular knockabout comedy Miranda.

The show, which is broadcast on BBC3 from tonight, zeroes in on Bluestone 42, a detachment of bomb-disposal soldiers held together by deep camaraderie and relentless banter. In some senses, it is a typical workplace comedy – it just happens to be set in a rather more extreme workplace than, say, The Office or The IT Crowd.

Download the new Independent Premium app Sharing the full story, not just the headlines

The team, led by the cocksure Captain Nick Medhurst (Oliver Chris, Green Wing) and overseen by the Lieutenant Colonel (Tony Gardner, Fresh Meat), exhibit all the familiar workplace gripes, such as complaining about the tasks they are made to do, bickering with colleagues, jostling for promotion and moaning about canteen food.

At one point, the Lieutenant Colonel tells Nick, who is eyeing up an endangered lizard as a tasty alternative to the fifth consecutive day of tomato pasta bake: "What's the first rule? If you want good food, don't join the Army. We should have stuck to what we know and invaded France." Teetering just the right side of insensitivity, Bluestone 42 strikes a balance between edgy and entertaining.

Hurst says there are similarities between Bluestone 42 and Miranda.

"In many ways, this is not that different from Miranda. It certainly has one foot in traditional sitcom. Like Miranda, it's about a group of people trapped together, and each week it weaves together three different plots."

But in many other respects, of course, Bluestone 42 is the polar opposite of Miranda. The series has already provoked criticism. The Conservative MP Patrick Mercer, a former Army colonel, has said: "I wonder if a comedy based in Afghanistan, considering the war is ongoing, is in the best of taste."

That Bluestone 42 could be deemed distasteful, or even offensive, is hardly surprising. Michelle Farr, the show's producer, says: "Whenever I tell people I'm doing a comedy about a bomb disposal unit in Afghanistan, they go, 'On no, you can't possibly do that.' But we've shown it to a lot of people connected to the military, and we have had no negative feedback at all."

Kelly Adams, best known for her role in Hustle, plays Mary, the unit's new Padre. She says, "Did I have reservations? Of course I did because it's a massively important subject. But as soon as people watch it, I don't think they will see it as offensive. In fact, the military people who've seen it said we have toned down their actual sense of humour. We couldn't put in the real stuff they get up to.

"I have enormous respect for the Armed Forces. They do something extraordinary for a living, but they're very matter-of-fact about it. They're the exact opposite of actors. We make a big deal about doing not very much!"

The executive producer Stephen McCrum admits: "When BBC3 announced the show, we had some complaints from people involved with the military – including one person had lost a child in Afghanistan.

"My approach was to ring these people up and talk to them about what we were trying to do. When we did that, we found they appreciated it. Once we explained we were trying to show the life that is lived by the people working out there, they came on board and became very helpful. And their reaction has been incredibly positive, I'm very relieved to say."

Hurst says they went to great lengths to ensure the series felt as authentic as possible. "We were worried because we didn't want anyone to be offended by it. So we did an enormous amount of research and talked to a lot of soldiers. We had a military adviser with us on set every day. We wanted to make something that soldiers would look at and say, 'Yeah, that's basically what it's like'."

Military personnel say Bluestone 42 feels authentic. A spokesman for the ARRSE (Army Rumour Service) website, a former major who served in Afghanistan, but does not wish to be identified, said Bluestone 42 was a convincing evocation of Army life. "The most important thing is that it is actually funny. It treats a serious subject with an appropriate degree of humour. The characters are all people that soldiers will recognise. They will say, 'yes, I know him,' or 'I've worked with that person'. It's also absolutely spot-on about how you do banter in the military.

"The people with the best sense of humour are the military. Humour is institutionalised in the Armed Forces. It's vital that people take the piss out of each other. Soldiers understand that risk is part of the job. If you get injured, you deal with it with black humour. That's an essential part of the human coping mechanism."

Banter is clearly a crucial element that glues the show – and the unit – together. James Cary says he conjured up the often unprintably rude language by, "Channelling my inner squaddie. I have the characters say things I think, but would never say, in public."

One perhaps surprising aspect of Bluestone 42 is that a character is killed within the first five minutes of the opening episode – not what usually occurs in a sitcom. "We had to create something where the danger to their lives was real," Hurst said.

"If we didn't have that, we would have ended up with a story that felt sanitised and untruthful. Viewers would have said, 'they do seem to wander through these incredibly dangerous situations and nothing bad ever happens to them.' We wanted to put a marker down at the very beginning to say, the soldiers' jeopardy is real, and we recognise that'."

There are precedents for such a show. Blackadder Goes Forth, Dad's Army and M*A*S*H were all memorable sitcoms set against the ostensibly unpromising backdrop of war and human tragedy.

Cary says: "The Armed Forces are pretty much the last respected institution in British life. We don't think much of politicians – in fact, we don't think much of many people. But we think an awful lot of our soldiers because, time after time, we ask them to do the impossible and they continue to deliver. I hope we reflect that in this show."

McCrum adds: "In Bluestone 42, we set out to celebrate those bits of the British Army that you don't see in documentaries. What I wanted to see in this show was the people behind the uniforms, the humanity, the banter, the camaraderie.

"The people I've met from the Army are exceptional. The least we could do was try to make a series that shows them some respect. We've made it absolutely clear they're doing a serious and dangerous job and are doing it with great professionalism. It was never our intention to make an ad for the Armed Forces – but that may well be what we have done."

It's certainly an immense change of gear for Hurst and Cary after the slapstick buffoonery of Miranda.

"We just wanted to get away from all that falling over," Hurst says, with self-mocking smile playing across his lips. "Having said that, there is some falling over later on in Bluestone 42. Thank God!"

'Bluestone 42' begins today at 10pm on BBC3