Mr Barr said the cadets were found to have had jihadist material and indecent images of children in their possession but are not accused of aiding the shooter.
The attorney general said 17 of the expelled cadets were found to have possessed online terrorist material. Fifteen, including some of the 17 who possessed online terrorist material, had indecent images of children, he added.
He said the 21 cadets were being disenrolled and returned home on Monday.
Mr Barr added that the expelled cadets had not been charged with any crime in the US, but might face prosecution back home.
There are more than 850 Saudi military cadets conducting training in the US. Their training was put on hold after the December attack.
Image copyright EPA
The attack last month occurred at the Naval Air Station Pensacola, Florida
The Pensacola base has long offered aviation training to foreign military forces. Saudi pilots started training there in 1995, alongside other personnel from Italy, Singapore and Germany.
After last month’s attack, the base’s commanding officer said that about 200 international students were enrolled in programmes there. According to its website, the base employs more than 16,000 military and 7,400 civilian personnel.