A freezing winter day in Cromer and it is impossible to tell where reality stops and Alan Partridge's world starts. "The best smiles for miles," says an advert for Cromer pier. "If hearty fun is good for the ticker," suggests another, GPs should prescribe "a strong dose of Cromer's seaside special". These Partridge-esque pronouncements are real but the pier shooting gallery and Susan Boyle poster are not. Two of a phalanx of police officers who have sealed off the pier from the public are genuine but most are actors watching the denouement of the long-awaited Alan Partridge movie.

The sheepskin gloves Steve Coogan is wearing when we shake hands must be Alan's? "They are actually mine," says Coogan, a little defensively, "but there is an overlap."

The closeness of the border between authenticity and fiction, and the territory shared by the 47-year-old actor and comedian and the hapless broadcaster he brought to life 22 years ago, is intriguing. They are also two good reasons for the longevity of the gauche and yet weirdly lovable Norfolk patriot whose career has been on the slide for decades and yet who has become deeply embedded in our culture.

On the set of Alan Partridge: Alpha Papa, it becomes clear that the Lexus-loving DJ is enjoying an unlikely career fillip. North Norfolk Digital (there is a real station called North Norfolk Radio) has been taken over by an evil media conglomerate and renamed Shape (catchphrase: "Own the Middle"). Partridge's colleague Pat, played by Colm Meaney, has taken the station hostage and is broadcasting live. Pat will only negotiate with the police through Partridge, who has never been the world's greatest diplomat, but is delighted by his return to the limelight. After a chase through Norwich in the roadshow van, the desperate DJs end up on Cromer pier, surrounded by police. It sounds like an ending.

A Partridge film has been planned for 10 years. An earlier version was reportedly scrapped after the 7/7 bombings because it featured Alan versus al-Qaida. While the Inbetweeners movie showed that small-screen comedy could make the leap to the big screen, that success has nothing to do with the timing of the £4m Partridge movie, which is made by Baby Cow, Coogan's thriving production company (as opposed to Partridge's bankrupt Pear Tree Productions) and part-funded by the BBC.

"I wanted to make sure I'd got my other plates spinning before I started this because I didn't want it to have the whiff of desperation of an 80s revival tour," says Coogan. "If it did, it would be sunk from the start." After a 2012 in which most of his public work concerned phone hacking, Coogan is now having an acting moment. This year he has starred as Soho porn baron Paul Raymond in The Look of Love and has co-written and appears opposite Judi Dench in Philomena, a forthcoming road movie about an Irish woman's search for her son. In keeping with his aptitude for playing real people, Coogan takes on the role of the former BBC journalist Martin Sixsmith.

Today Coogan is lying prone on Cromer pier in a wig, sports jacket, blue jeans and white Dunlops, finessing a joke about a seagull (should he mention Jonathan Livingston Seagull or not?) as real seagulls wheel in a gunmetal grey sky, which starts to deposit real flakes of snow.

Clutching a hot water bottle between takes, Coogan emanates intensity. In rehearsals, conducted in the gloomy end-of-the-pier theatre, he reminds Felicity Montagu, who reprises her role as Lynn, Alan's loyal PA, of her lines. For a moment, it resembles Alan and Lynn's fictional relationship. In Montagu's defence, she is working on the film by day before racing back to the West End to perform in Quartermaine's Terms at night; one evening she forgot to remove Lynn's mole for her theatrical duties.

Why has Partridge proved so enduring? "Everyone loves a bigot, don't they?" says Montagu. "He says things he shouldn't say and people dream about saying things they can't say. Deep down Alan is a good person. He behaves like a shit but he's quite vulnerable and lovable really." And Coogan? "He's a taskmaster but that's all right," says Montagu jollily.

As lead actor, writer and keeper of the Partridge flame, Coogan dominates the 140-strong crew. The director, Declan Lowney, a veteran of Father Ted and Little Britain whose shoulders heave with silent laughter as Coogan surprises with another new interpretation of the seagull scene, is not put out. "It's bloody brilliant because he's so fucking clever and he's so on his game," says Lowney. "He knows his character better than anyone so it's hard to contribute. All you can do is facilitate and give him the space."

Coogan was 26 and known for his Spitting Image impressions when he invented Partridge with Patrick Marber for Radio 4's On The Hour. Alongside Chris Morris, Partridge graduated to 24-hour news satire The Day Today and then spoof chatshow Knowing Me, Knowing You. A washed-up Partridge reappeared on Radio Norwich's graveyard slot "Up with the Partridge!" for 12 episodes of I'm Alan Partridge either side of the millennium, then his mic fell silent until he was revived for Coogan's 2008 standup tour and an unexpected series of internet shorts.

One reason for Alan's longevity, thinks Coogan, is that he has never been overexposed. "We haven't jumped the shark, yet. We've managed to avoid that by not churning them out," he says. "Although I want a lot of people to like him, I'd rather have his DNA preserved." Coogan could have made another TV series but chose the internet to "do it in a sort of undergroundy way to preserve a bit of cachet"; another unexpected step was I, Partridge, an autobiography that attracted rave reviews in 2011.

Marber was Coogan's first co-writer, before Armando Iannucci and later Peter Baynham stepped in. Both have contributed to this script but Coogan's principal writers now are "the boys", as he calls thirtysomething twins Rob and Neil Gibbons. They wrote some lines for Coogan's tour "and it was a revelation," says Coogan, who is rarely effusive. "I thought, oh my God, they understand [Alan]. A lot of people think they understand but their judgment is slightly wrong, and slightly wrong is as bad as being very wrong. It's either on target or it's not."

As everyone on set points out, Partridge is a deceptively nuanced individual. Kevin Loader, the producer, has a big list of naff, Alan-appropriate songs but says he can never predict which ones Partridge, via Coogan, will like. "There's a saloon bar tendency to think it's like a Harry Enfield sketch character and it's not," he says. "These are very comic two-dimensional characters, very funny, but Alan Partridge is the antithesis of that. He's a novelistic creation."

Partridge has evolved during his 22‑year life. In the beginning, some of the humour was based around him being an old man in a young man's body. These days, the DJ is a lithe 55, with a tendency to use "street" language. "He's tried to move with the times," says Coogan. "He's aware of political correctness but he's playing catch-up. In the same way that the Daily Mail is a bit PC – it wouldn't be openly homophobic now – Alan is the same. He tries to be modern."

Between takes, Neil and Rob Gibbons earnestly consult with Coogan over lines before joining in the silent laughter when he delivers them. Coogan "is a perfectionist," says Neil. "He's absolutely fizzing with ideas all the time. He's got a very restless mind."

"His ability to improvise a good line on demand is ridiculous," adds Rob.

As I check whether the Jim Davidson leaflets on Cromer pier are real or not (they are), the brothers reveal they once wrote jokes for him. With Partridge, they have tried to avoid obvious gags; Alan does not utter "A-ha!" once during the film. "If Alan has talked about it before and a fan might quote it back, we run in the other direction," says Rob.

Every night, Coogan and the Gibbonses go over the next day's script; half of it is scrapped and rewritten. "Steve just absolutely insists on trying to keep it fresh and spontaneous," says Rob. "You have to learn not to be attached to good jokes. If we were, we'd be grumpy all the time because they end up going in the bin. It's gruelling." If this obsessive perfectionism is what you might expect of Coogan, the Gibbonses point out that, unlike every other comic writer they know, Coogan doesn't even remember who comes up with a funny line; he is simply obsessively focused on making it as good as possible. "There's no ego," says Neil.

After a day on Cromer pier, I still cannot see where Alan ends and Steve begins. It is not just me. Partridge's obsession with Cromwell, cars and Nazi trivia is Coogan's own, says director Declan Lowney. "There's a lot of times when Steve says something hilarious and 'Alan Partridge' and you write it down and then you realise it wasn't meant as a joke and it was Steve Coogan," says Neil Gibbons.

I follow Coogan's fast-moving white Dunlops up the cliff and back to the hotel. "It started out not being like me at all. It's probably got more like me," puffs Coogan, as the wind buffets his impeccable Partridge hairpiece. "It's recognising your own vanities and insecurities and turning the volume up on them. Anyone who is creative puts something of themselves in what they do, and I've put lots in, but it's the warped, prejudicial side of myself. It's not just a mocking caricature. It has to have some degree of humanity. On one level, Alan is very likable because he makes mistakes and vocalises a lot of the insecurities that people feel. He's also a contemptuous Little Englander, the kind of person who I see as my life to rail against. Part of him is everything I hate about Britain. It's a bit complicated."

• Alan Partridge: Alpha Papa is released in the UK on 7 August.

• This article was amended on Friday 2 August 2013. In the above interview we said that the film Philomena involved an Irish woman's search for her daughter. In fact, she is searching for her son. This has been corrected.