An Australian judge has sentenced a Sri Lankan man to 12 years in prison for threatening to detonate a fake bomb on a Malaysia Airlines flight, terrifying more than 200 passengers and crew.

Manodh Marks forced Flight 128 bound for Kuala Lumpur, Malaysia, to turn back to the Australian city of Melbourne soon after takeoff in May last year when he screamed that he had a bomb and ran down the aisle carrying a flashing electronic device.

The 26-year-old was sentenced on Thursday after pleading guilty in a Melbourne court to attempting to take control of an aircraft, an offense that carries a potential maximum penalty of 20 years in prison.

The drama came after Malaysia Airlines lost two Boeing 777s in 2014.