It is one of the biggest bets ever placed on Atlantic City and, given the New Jersey resort's century-long love affair with vice and gambling, that really is saying something.

Cable television channel HBO has staked tens of millions of dollars on a new drama series set in the seaside town that has long been a byword for corruption, crime and wild times.

Drawing on a backdrop of Atlantic City's 1920s prohibition era heyday, Boardwalk Empire could end up being the biggest drama series HBO has ever produced. The pilot episode, which cost at least $20m, was directed by Martin Scorsese and the series is being scripted by Terence Winter, one of the creative forces behind TheSopranos. It will star Steve Buscemi as Enoch Thompson, a criminal godfather based on the real-life figure of Enoch "Nucky" Johnson, who was the ultimate power-broker in Atlantic City for decades, leading a life of crime, debauchery and Robin Hood-style gifts to the poor.

HBO has wagered its reputation on the show. It has built a $5m set, cast hundreds of actors and sold it to 160 countries, based purely on a viewing of an unfinished version of the pilot. The buzz surrounding Boardwalk Empire is huge, but it is not just the cable network that is praying for a triumph. The real-life Atlantic City is hoping for a boost too, one that could rescue it from its 21st-century disaster.

Atlantic City looms out of the coastal marshes like a vision of Las Vegas transplanted to the Jersey shore. The bulky shapes of its 11 gigantic casinos, blaring familiar names such as Caesars and Bally's in bright neon lights, can be seen from miles away. They line the old wooden boardwalk that was once the heart of Atlantic City and that last week was filled with thousands of tourists eating fried food, riding on a Ferris wheel or just parading up and down in the stifling August heat.

It seemed a picture postcard of a town doing well – but that, sadly, is an illusion. The Atlantic City of today is a far cry from the booming days of the 1920s that have so captured the imaginations of HBO's creative minds and that inspired Scorsese. The town is in many ways simply going bust. Hit by the double blow of the recession and the opening of rival casinos elsewhere in the region, Atlantic City's economy has sunk into the mire. This year revenue from casinos is down 30% from four years ago and 12,000 jobs have been shed. Seven of the city's 11 casinos operated at a loss for the first quarter of the year.

The crisis is so profound that the New Jersey governor, Chris Christie, recently proposed a sort of state takeover of the governance of the casino industry and the boardwalk. Christie now wants to do the once unthinkable and turn Atlantic City into a "family-friendly" destination. "Atlantic City is dying," Christie declared bluntly, adding: "If anybody's got a better idea, come forward with it."

Such harsh language might have been expected to anger and annoy the locals, but not here. Everyone knows Atlantic City is in deep trouble. The problems are not hard to see. Just a few blocks back from the boardwalk, Atlantic City is a picture of urban blight. Empty lots line streets dotted with dilapidated housing and shops with boarded-up windows. There are few signs of the resort's golden age as a glamorous beach destination. Once-famous hotels and nightclubs have been knocked down and buried beneath the modern behemoths of gambling. Visitors now while away the hours in windowless caverns full of slot machines and gaming tables.

Beyond that, the surrounding town has withered away. While its population was 66,000 in the 1930s, Atlantic City is now home to 35,000 people, many of whom are struggling – recent figures put the poverty rate at 24%.

Mary Hill, a 60-year-old sitting on her porch last week just a few blocks from the Trump Taj Mahal, worked at a casino for 27 years before the constant standing forced her to have two knee-replacement operations. She lost her job when the casino told her she had taken too much time off work sick. "I put 27 years into that casino and this was my reward. It bothered me what they did," she said.

Such stories are common in Atlantic City as it stares into an uncertain future. Asked about the governor's suggestion that the resort was dying, Herbert Hartman, a local estate agent and event organiser, responded: "I think Christie was understated. Things are that bad." Hartman, a familiar and influential figure in the city's social life, was speaking from a seat in the elegant Art Deco lounge of the Ritz building – a survivor from the era before the corporate casinos were built in the 1980s and 1990s. It harks back to the time that is being re-created by Boardwalk Empire. Indeed, it was the very place from which "Nucky" Johnson ran Atlantic City.

In the 1920s and 1930s, Johnson rented the entire ninth floor of the building, which was then a plush Ritz-Carlton hotel. Wearing the latest fashionable suits and with a fresh red carnation pinned to his lapel every day, Nucky did deals with government officials and mobsters such as Al Capone and Lucky Luciano. He openly flouted the alcohol ban, turning Atlantic City into a booming vice town.

Walking down the corridor of the Ritz's ninth floor now (which has been turned into private apartments), Hartman let his imagination run wild. "Can you imagine Capone and Luciano and Nucky with all those showgirls and booze?" he said. "It would have been fun."

That is exactly what HBO executives have been doing. The TV series is based on the book Boardwalk Empire by local judge Nelson Johnson. He researched and brought to life the outsized story of Nucky and the prohibition era in the city and is looking forward to seeing it brought to life on the small screen. "It captures the spirit of the age. The flamboyance and the colour. It was the high times of old Atlantic City. That was really the zenith for the city," Johnson said.

Trailers released ahead of the September launch of the show reveal the lavish adaptation in its full glory. No expense has been spared in the attention to detail. For the 12 episodes shot so far, a 300ft re-creation of the 1920s boardwalk has been built. There are more than 300 crew members, 225 actors with speaking roles and 1,000 extras. Attention to detail is extreme. For example, the show begins in 1920 at a time when the safety razor was only just being introduced and a shave in a barber shop was still for the rich. Producers decided that about 50% of background male extras should have facial hair. But as the series progresses through the 1920s – and, historically, the razor became more popular – that percentage will drop.

It is a mammoth project. Yet none of it is taking place in Atlantic City itself. Instead, the enormous set has been built in Brooklyn in New York. "The Atlantic City boardwalk of the 1920s does not exist any more," said Johnson.

But some in the city are still hoping to cash in. Hartman, who has an office in the Ritz building, is hoping that viewers of the show might decide to visit Nucky's old stamping grounds, as Sopranos fans do when they hunt for the fictional Tony Soprano. "People are excited to hear about the series. We should be promoting this as a city. It is so nice to have a worldwide focus on you," said Carla Linz Callaway, a senior editor at the local paper, the Press of Atlantic City.

It is certainly a rare ray of light in a seemingly bleak outlook for Atlantic City and perhaps a reminder of how much has changed. Almost everything from Nucky's era has gone. The city is half the size; it is dominated by casinos run by out-of-town companies; the 1920s buildings have nearly all been knocked down; the feel of a boom town in decadent times has been replaced by a city in crisis, searching for a role in a new austere age. Only the aims of the out-of-town visitors thronging the boardwalk remain the same.

"In Nucky's day, people came to Atlantic City to drink and party and gamble," Hartman said. "Now, they come here to drink and party and gamble. It has not all changed."