Editor's Note — Warning, the embedded video contains offensive language

(CNN) — Pilots are trained for landing in all kinds of weather conditions, but as a new video of an airplane buffeted by high winds revealed, they also know when to admit defeat.

The video shows a British Airways flight that was forced to divert from its planned course after encountering strong gusts off the coast of southern Europe on Monday.

Flight BA492 was scheduled to take off from London Heathrow airport at 8:25 a.m. and land in the British overseas territory of Gibraltar at 12:20 p.m.

However, it eventually touched down at 12:41 p.m. in the southern Spanish city of Malaga after strong winds prevented it from landing in its intended destination.

Video footage of the incident, which contains some strong language, shows the plane see-sawing from side to side as it struggles against the wind.

It was filmed by Richard Whalley, who told CNN: "I work in the port, it's closed due to the high winds so was just in my office. (I) heard loud engine noises so looked out and saw the plane doing funny maneuvers."

British Airways told CNN that passengers left the flight normally and the company was arranging ground transport so that they can continue their journey to Gibraltar.

"Due to strong winds in the Gibraltar area, our pilots decided to land in Malaga as a precaution," said the airline in a statement.

British Airways apologized to customers for the disruption to their journey. "At no point was there a risk to safety," the airline said in a statement. "The safety of our customers and crew is always out number one priority."

Airplane pilots are extensively trained in landing and maneuvering in high winds and can safely abort a landing right down to the moment when the wheels are touching the ground.

The plane involved in Monday's incident is an Airbus A320 which has a capacity of 100-240 passengers, according to the company

Related content When your plane touches down but doesn't land

It is known as a global short- to medium-range workhorse, which has proven popular with airlines around the world.

"The A320 has a fantastic safety record," Phil Seymour, the president of the International Bureau of Aviation, told CNN in 2015.