TORONTO -- Second Cup wants to serve up a different kind of buzz by converting some of its coffee shops into cannabis dispensaries and, when legal, pot lounges.

Shares in the Canadian restaurant operator rose as much as 31 per cent before closing up 28.73 per cent at $3.54 on Thursday after it announced that it has signed an agreement with marijuana clinic operator National Access Cannabis to develop and operate a network of recreational pot stores.

However, neither currently has a licence to sell marijuana, so the deal is contingent on approval from the government, as well as from franchisees and landlords.

If and when regulations allow, the two companies also want to open coffee shops for cannabis consumption, said Second Cup's board chairman Michael Bregman.

"(Cannabis) is going to be an awfully big business in Canada, and we have some amazing locations," he said in an interview Thursday. "I wish I knew now in what form we would be pursuing and participating. We're just trying to position ourselves so we can participate as the opportunities arise and the legislation is formed."

Second Cup, once a pioneer in the world of upscale coffee, has been struggling to find its place in an increasingly competitive cafe market and has been losing market share to more dominant players, including Starbucks and Tim Hortons, as well as to increasingly popular independent craft purveyors of java. Canada's second-largest specialty coffee retailer reported adjusted net income of just $110,000 for fiscal 2017.

And so, the coffee chain, like many other Canadian companies, is jumping in to grab a piece of the lucrative marijuana market.

The companies said in a joint release Thursday that the NAC-branded stores would initially be located across Western Canada, with plans to expand to additional provinces where legally permissible. NAC, which operates a network of marijuana patient advisory clinics, will apply for licenses to dispense cannabis products and work with Second Cup and applicable franchisees to construct stores. NAC has signed marijuana supply agreements with CannaRoyalty Corp. and others.

Canada is preparing for the legalization of recreational marijuana later this year, but the distribution model for pot differs widely between provinces.

Private operators will be able to sell marijuana, after obtaining the appropriate licenses, in provinces including British Columbia, Alberta, Saskatchewan and Manitoba. NAC is already among the organizations selected by Manitoba's government to handle retail sales of recreational pot once legal.

Provinces such as Ontario, Quebec, New Brunswick and Prince Edward Island, however, will sell marijuana in outlets run by the provincial liquor commissions.

Retailers, pharmacies and licensed cannabis producers are already positioning themselves for the green rush.

Shoppers Drug Mart's parent company, Loblaw Companies Ltd., has applied for a license to dispense medical marijuana, and has signed supply agreements with pot producers.

And in February, licensed producer Aurora Cannabis Inc. signed a $103.5-million deal to buy a minority stake in Liquor Stores N.A. Ltd, which plans to launch a brand of cannabis stores.

Meanwhile, many provinces and territories have said they are restricting the consumption of cannabis to privately owned residences but some jurisdictions such as Ontario are soliciting feedback on whether to allow for licensed cannabis consumption lounges.

NAC chief executive Mark Goliger said in an interview Thursday that "the minute that that becomes a legal option, we will be first in line."

While the details of those consumption lounges would depend largely on regulations, he described them as "Amsterdam, with Canadian conservativeness attached to it."

"We do feel that cannabis lounges are a logical next step ... As most provinces are making it very restrictive as to where people can actually consume in public," Goliger said.

Shares of NAC on the TSX Venture Exchange were up as much as 14 per cent to $1.04 on Thursday after the announcement.

Bregman said Second Cup got the idea to branch out into pot after being approached by several cannabis producers. The coffee chain "felt comfortable" with NAC as a partner, and signed a deal on Wednesday night, he added.

As well, NAC has issued to Second Cup warrants to purchase 5,000,000 common shares of the company, at an exercise price of 91 cents per share. The warrants expire in April 2023.

It's unclear how many stores -- which will be under a new brand developed by NAC, according to Goliger -- will be ready by legalization, expected later this year. The companies plan to submit as many as 20 applications for licenses to the Alberta government, and see how many get approved, said Bregman.

Conversion of any Second Cup cafes to dispensaries will be conditional on obtaining a license from provincial regulators as well as the approval of the applicable franchisee and landlord. Store ownership will be split 50/50 between the two companies, or the two parties would split the balance if a franchisee is included, he added.

Second Cup's Bregman said the coffee chain's efforts to revamp are paying off, but it has a long way to go. Second Cup plans to continue expanding its network of coffee shops across Canada as it develops a network of cannabis dispensaries with "compelling" economics, he added.

"This is an opportunity where there is plenty of potential upside and no real downside," said Bregman. "This can't hurt the company, can't hurt the franchisees. But can help a lot if things go well."