A Federal Court judge has ruled that medical marijuana patients have the right to grow their own cannabis.

Judge Michael Phelan struck down federal legislation introduced by the previous Conservative government that barred patients from growing their own plants and required them to buy from licenced producers.

He is suspending the decision to strike down the law for six months, allowing the federal Liberal government time to create a new medical marijuana regime.

Phelan also extended the injunction that allowed people who held licences to grow their own marijuana to continue until a further court order.