The Cambodian-Spanish War    was an attempt by the Spanish Empire to conquer Cambodia, establish their own king, and Christianize the population. Along with the Spanish, the Japanese, Filipinos, Thai, Portuguese, and Dominicans participated in the invasion of Cambodia. Each country possessed different motives for their invasion of Cambodia. Specifically, the Thai interference and the Spanish expedition was a result of a power struggle between rival factions in Cambodia's government. In addition, both Spanish and Portuguese took part in the invasion of Cambodia because King Philip II ruled both Spain and Portugal. In February 1593, Thai ruler Naresuen attacked Cambodia in order to fight the Burmese. Later on, in May 1593, 100,000 Thai  soldiers invaded Cambodia. As a result of the Thai's invasion, Lovek was conquered in July 1594. In 1593, the Spanish expedition led by Gregorio Vargas Machuca and Blas Ruiz de Hernan Gonzales entered Cambodia through the city of Manila.Although the Spanish invasion of Cambodia  failed, Ruiz and Veloso succeeded in establishing king Barom Reachea II in May 1597. Private individuals of Muslim Malays, Chams, Cambodians retaliated to Spain and Portugal's invasion by slaughtering the Spanish and Portuguese, including Diogo Veloso. Only a few Filipinos and one Spaniard survived the massacre. Because of the massacre, Spain's planned Christianization of Cambodia failed. After the attack, Cambodia came under the dominance of the Thai in July 1599.

why did both Spain and Portugal have to attack Cambodia?
King Philip II ruled both