At the moment last week when marijuana entrepreneur Ross Vaisman received a license to open his recreational cannabis storefront on West Colfax Avenue, he made history as the first person in Denver to beat back an effort by city officials to stymie his plans.

The license granted Thursday to the Pig N’ Whistle came after a circuitous 15-month legal battle involving an initial denial by the Department of Excise and Licenses in March 2015, numerous challenges and appeals from the city and applicant and finally orders from two Denver district judges in Vaisman’s favor.

It marked the first time a denial of a license for recreational pot sales had been overturned in Denver.

“The law has spoken loud and clear,” Vaisman told The Denver Post on Monday. “I have the right to sell recreational marijuana at the Pig N’ Whistle location.”

But it’s a right that cost Vaisman what he estimates was at least $3.7 million in lost revenue while he waited for his case to be resolved. And it’s a case that points to the road bumps Denver continues to face in trying to lay down rules for the state’s most prolific retail marijuana sector — as of April Denver had 211 grows, 147 stores and 63 locations with both.

The sheer number of cannabis operations in the city prompted City Council members to impose a cap in April.

“I think it’s only natural that something this new is going to go through legal gymnastics,” said Dan Rowland, a spokesman with the Department of Excise and Licenses. “As stringent, strong and equitable as our regulations are, there are always nuances to each case.”

The department is in the midst of considering whether, for the first time, to deny a Denver marijuana grow facility the renewal of its license after neighbors complained of odors emanating from Starbuds’ operation at 4690 Brighton Blvd., near the National Western Stock Show complex.

Neighbor outcry was also at the root of the department’s decision last year to deny the Pig N’ Whistle its license.

The department’s director, Stacie Loucks, ruled in March 2015 that opening the pot shop at 4801 W. Colfax Ave. would “adversely impact the health, welfare and public safety” of the neighborhood, even though a hearing officer from the department had determined that the store met all of the city’s setback requirements.

Loucks determined that The Brandon Center for Women and Children, The Volunteers of America Family Motel and religious school Talmud Torah Zera Abraham, while not strictly meeting the definition of daycare centers or schools, were similar enough to those institutions to trigger the setback rules and block the license.

But when a district judge in January made it plain that city officials had “abused their discretion by arbitrarily and capriciously misconstruing and misapplying the law,” Vaisman’s attorney, Tom Downey, said that should have ended the matter. Yet the city continued for more than four months to refuse the Pig N’ Whistle its recreational cannabis license, claiming in part that the store would have to go through another hearing to show compliance with tougher licensing rules the city had put in place as of the beginning of 2016.

Downey, who once served as director of Denver’s Department of Excise and Licenses, was perplexed by the city’s decision to fight the licensure of the Pig N’ Whistle — which sits at the spot where the namesake historic West Colfax motel once stood — as hard and long as it did.

“My thought was disbelief — legally it made no sense,” he said.

Acting Denver city attorney Shaun Sullivan told The Post on Monday that his office advised Loucks in her decision and that it “diligently defended the denial of the license in district court.”

Last week, a different district judge ruled that the city had no right to retroactively apply new rules to a business that had applied for a license under old rules. Vaisman hopes to have the recreational side of his business — he opened a medical marijuana storefront in part of the Pig N’ Whistle building last year — open by the end of June.

“Probably, the most overwhelming emotion I have is to get back to business and back to real work,” he said.

Downey said the long battle is a testament to his client’s fortitude in standing up for what is right.

“The city has great power, but it’s not unlimited,” he said.