Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Airline passengers in Canada were saved from an incredibly dangerous flight this New Year's Eve, when their intoxicated pilot allegedly passed out in the cockpit before being arrested, according to the Calgary Police Service.

Police said the Sunwing Airlines cabin crew notified authorities after they noticed the pilot behaving "oddly" as he boarded the flight bound for Cancun, Mexico. Police later arrested the pilot and charged him with two counts of controlling an aircraft while impaired and controlling an aircraft while intoxicated, police said.

Jacqueline Grossman, a spokesman for the airline, told Canada’s national news agency, CBC, that the company appreciated the crew’s “diligence in handling this very unfortunate matter.”

“We are very apologetic for any upset that this has caused and would like to assure our customers that safety remains our utmost priority,” she said.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The aircraft had 99 passengers onboard and six flight crew, including the pilot, police said.

The Canadian pilot’s arrest Saturday follows another incident earlier in the week that forced to Indonesian airline executives to resign after one of their pilots was suspected of trying to fly a plane while drunk.

Citilink President and Director Albert Burhan announced Friday that he and the airline's production director would step down over the controversy. The budget airline is a subsidiary of national flag carrier Garuda Indonesia.

Passengers became suspicious when they heard slurred words and unclear announcements from the cockpit. Some passengers filmed the announcement and posted them online, others left the plane and asked for a replacement of the pilot they believed to be either drunk or under the influence of drugs.

Related: ‘Air Rage’ Forces Delta Flight as Cases Soar

Citilink assigned a new pilot to fly the Airbus A320 about an hour behind schedule. The flight had 154 passengers but a number reportedly decided to cancel.

The flight on Wednesday was heading from Surabaya, Indonesia's second-largest city, to the capital, Jakarta. Aviation is a main mode of travel in the sprawling nation of 17,000 islands, and the incident has raised safety concerns.

YouTube footage shows the pilot appearing to stagger through a metal detector at a security checkpoint and security guards picking up items that clattered to the floor as he attempted to pick up his bag.

"The pilot had committed serious violation of standard operation procedure that endangered passengers," Burhan said. "We apologize for the discomfort. I have to be responsible for that and therefore I and my production director resign."

The airline previously had dismissed reports that the 32-year-old pilot Tekad Purna was drunk, saying initial tests of drug and alcohol were negative. Purna is under investigation for possible drunkenness or drug use. Minister of Transportation Budi Karya has banned him from flying pending the outcome of the investigation. If proven, his license would be revoked.

In December last year, three crew members — a pilot and two flight attendants were arrested for allegedly consuming crystal methamphetamine, known locally as shabu-shabu, at a hotel.