The Supreme Court on Wednesday ordered a US Marine convicted of rape to be moved from the American embassy into Philippine custody, reopening an emotional case that has become a rallying point for anti-American protests. The court ruled that a deal allowing Lance Cpl. Daniel Smith to stay at the embassy while appealing his 40-year jail term was contrary to the Visiting Forces Agreement, which governs the conduct of US forces in the country. The justices instructed Foreign Secretary Alberto Romulo to negotiate Smith's transfer to an appropriate detention facility. Pending such an agreement, Smith can remain at the embassy, the court said. It also directed the Court of Appeals to quickly resolve Smith's appeal. The US Embassy issued a statement saying it would consult with legal experts in Washington. The rape case has stirred emotions in the former US colony and became a rallying point for activists demanding an end to US military counterterrorism exercises. Smith, 23, from St. Louis, Missouri, was detained and put on trial in 2006 after a woman accused him of rape. After sentencing, he was transferred from a local jail to US custody while his case was on appeal. When a Filipino judge initially ordered Smith be detained in a suburban Manila jail, the US government temporarily suspended joint, large-scale military exercises in protest. Washingon agreed to proceed with the annual Balikatan war exercises with the Philippines only after Smith had been transferred to the embassy. President Gloria Macapagal Arroyo backed the US position and said Smith's embassy detention was necessary to avoid complications in relations with its key ally. A provision in the 1998 Visiting Forces Agreement states that any accused US service member shall remain in American custody until all judicial proceedings are exhausted. The Filipino woman's lawyer, Evalyn Ursua, and the left-wing alliance Bayan claim Smith should be serving his sentence in a Philippine jail, regardless of his appeal.