An American driver says Tesla's automated driving features saved his Model S from being hit from the side by a truck crossing his lane on an interstate highway.

Joshua Brown posted a dashcam video of the near collision on YouTube on April 5. The video has gone viral since it was tweeted by Tesla CEO Elon Musk this weekend.

Owner video of Autopilot steering to avoid collision with a truck<a href="https://t.co/FZUAXSjlR7">https://t.co/FZUAXSjlR7</a> —@elonmusk

Brown said he had been driving with the car in Autopilot mode, a feature enabled by a software update released last October. Autopilot uses a combination of cameras, radar, ultrasonic sensors and data to allow newer Teslas to automatically perform certain actions, such as keeping the car within its lane and maintaining a certain distance from the car in front while on a highway. It also provides warnings of potential collisions.

Brown was driving on the interstate in Cleveland when a boom lift truck merged onto the highway from the left.

"Once the roads merged, the truck tried to get to the exit ramp on the right and never saw my Tesla," Brown wrote on YouTube. "I actually wasn't watching that direction and Tessy (the name of my car) was on duty with Autopilot engaged. I became aware of the danger when Tessy alerted me with the "immediately take over" warning chime and the car swerving to the right to avoid the side collision."

At that point, the car had already gotten out of the way, but Brown took over the steering and slowed down as best he could to put more room between himself and the truck.

"I have always been impressed with the car, but I had not tested the car's side collision avoidance. I am very impressed," Brown wrote.

Aarian Marshall, a transportation writer for Wired, suggested that Brown might have avoided the truck anyway if he had been driving himself instead of using Autopilot.

"In fact, the awesome news … is not that the car saved someone from danger: It's that the car worked exactly as it should have," Marshall wrote. "And even better, the technology that let it spot an oncoming accident and leap to safety is about to get a lot more common."

Volvo introduced automatic emergency braking as a feature for its XC90 luxury SUV in 2014, along with a feature that detects when a car has drifted onto a soft shoulder and automatically pulls it back onto the road.

Last September, 10 major vehicle manufacturers agreed to make automatic emergency braking a standard feature in all new vehicles to reduce the chance of collisions. Toyota plans to offer the feature as an option for almost all its models by the end of 2017 for $300 to $500.

Tesla's own emergency braking feature has previously been credited with preventing collisions.