Prosecutors said Elton Skenderi, 29, Gjovalin Toma, 31, and Eduard Daja, 39, operated the factory from abandoned industrial units at a derelict shopping centre in Irvine, Ayrshire.
Following a search of the property, police officers recovered thousands of cannabis plants which had been grown inside three units at the Forge Centre.
All three men were sentenced at the High Court in Glasgow after admitting being concerned in the supply of cannabis between September 14 and September 25 last year.
Daja, who also pleaded guilty to an immigration offence, was imprisoned for six years and nine months.
Skenderi was sentenced to five years and three months in jail, while Toma will spend six years in custody.
Moira Orr, who leads on major crime for the Crown Office and Procurator Fiscal Service (COPFS), said:
“These three individuals were cultivating and supplying illegal and harmful drugs on an industrial scale.
“However, they are now serving lengthy prison sentences thanks to an extensive police operation, working with COPFS, to investigate a network of drug supply.
“With each case of this kind we can help reduce the harm that these drugs inflict on Scotland’s communities.”
The factory had been set up in shuttered units at the disused former Forum Shopping Centre in Irvine, Ayrshire.
Police investigated after they received information from Scottish Power related to the energy usage at the premises.
Officers also heard from a witness who described frequently seeing individuals carrying several black bags from a large white van into the premises in the early hours of the morning.
A search of the premises in September 2024 then revealed the scale of the cultivation of the Class B drugs throughout several floors of the units.
In total, 3058 plants were recovered with an estimated street value of up to £1,834,800.
There had been a barricaded door to try and stop the authorities getting in together with CCTV set up outside.
Inside, there were also evidence that the units had been used as living quarters which included a bedroom, a cooking area, an electric heater as well as tables and chairs.
Skenderi and Toma were apprehended the same night trying to avoid the police and Daja was caught the next day after being spotted leaving a fire exit at the shopping centre.
Fingerprint and forensic evidence linked Skenderi and Daja to the crime scene.