LOS ANGELES — A federal judge ruled Thursday that a cross on federal land in San Diego violated the First Amendment ban on a government endorsement of religion and ordered it removed within 90 days.

But the quarter-century fight over the 29-foot cross atop Mount Soledad may not be over. The judge said he would stay the order if there was an appeal. The case has wound through the courts since the 1980s, while the cross has become emblematic of the national debate over the place of religion in public life.

After a previous cross at the site was knocked down in a windstorm, the current cross was erected on city property in 1954 by the Mount Soledad Memorial Association, a veterans’ group, who called it a monument to Korean War veterans. In 1989, Philip K. Paulson, a Vietnam War veteran and an atheist, sued the City of San Diego to have the cross removed, and the case has remained in court ever since.

Supporters of the cross have argued that it remains a war memorial, not a religious symbol, even though few if any commemorations of war victims were at the site until after Mr. Paulson’s lawsuit.