COPENHAGEN, Denmark (AP) _ The leaders of Cambridge, Mass., spoke, and Denmark's crown prince listened. The Royal Palace said today that Frederik will not live in a rent- controlled house while he goes to Harvard University.

City officials in Cambridge and news media raised an outcry after it was learned that Harvard had arranged for the heir to the Danish throne to live in the three-bedroom house during his year of study.

Although the house rents for $1,900 a month, critics said it should be reserved for people with low or moderate incomes.

Harvard officials said the prince needed the house because he will be accompanied by bodyguards and aides. But a palace spokesman said today that Frederik would move into an apartment near Harvard.

''We gave up the house only because the case was brought up by the city council and in the papers,'' said Niels Eilschou-Holm, private secretary to Queen Margrethe II, Frederik's mother.

''We heard of the problems in early June. We are not interested in having problems with anyone, so we found another place last week,'' Eilschou-Holm said.

The 23-year-old crown prince will share the apartment with another Danish student, Holger Foss, the palace said. Frederik plans to take several undergraduate courses but will not be trying to earn a degree.

When Frederik attended political science lectures at Aarhus University in western Denmark, he and Foss lived in the nearby Marselisborg Castle, owned by the royal family.