Kabul, Afghanistan (CNN) -- A mentoring session for Afghan police spiraled out of control and ended in a shootout that killed two Spanish soldiers, an interpreter and a rogue police officer in western Afghanistan Wednesday, a statement from NATO-led forces said.
The Afghan police officer began firing a gun and the Spanish soldiers returned fire, according to NATO's International Assistance Security Force (ISAF). Officials were trying to determine why the Afghan officer opened fire.
The shootout occurred at the Qala-i-Naw base in Badghis province, according to the Spanish Interior Ministry. Several people protested afterward, ISAF said.
"This incident is a tragedy for the families of the Spanish soldiers and the interpreter. We express our condolences to them," said ISAF spokesman Brig. Gen. Josef Blotz.
Spanish Interior Minister Alfredo Perez Rubalcaba told reporters Wednesday that despite the tragedy, Spain will continue training Afghan forces because that is essential in order for foreign troops to withdraw from Afghanistan.
He said the two Spaniards who died -- Capt. Jose Maria Cordoba Galera and Ens. Abraham Picallo Leoncio Bravo -- were both 33 years old and belonged to the Civil Guard. The interpreter who accompanied them was an Iranian-born Spaniard.
Blotz said NATO soldiers train thousands of Afghan army and police every day and Wednesday's incident was "isolated."
A new system has recently been put in place to scrutinize new Afghan recruits more closely, Blotz said. The process includes a criminal record check, looking for ties to insurgents and obtaining biometric data.
The Spaniards are training the Afghan police in a course that is intended to improve professional skills, according to ISAF's website.
In southern Afghanistan, a roadside bomb killed three Afghan civilians, ISAF said. The explosion occurred in the Arghandab district of Kandahar province.