President Reagan arrived here today from his troubled visit to West Germany and immediately encountered a new set of controversies over the U.S. military presence in Spain and his Central American policies.

There was no repetition of yesterday's nationwide demonstrations that brought tens of thousands of Spaniards into the streets to protest Reagan's policies. But tonight, as Reagan and his wife, Nancy, dined with Spanish King Juan Carlos and Queen Sofia at their Zarzuela Palace residence, anti-Reagan demonstrators staged additional protests.

At 10 p.m., residents of blue-collar and student neighborhoods around the capital switched off lights, banged saucepans and honked car horns. The protest was organized by the same leftist and union groups that staged yesterday's demonstration.

When he arrived from West Germany this afternoon, Reagan was warmly greeted by the king, who joined him in a brief military ceremony at the airport.

Friendly crowds waved U.S. and Spanish flags and cheered Reagan and the king on their long motorcade to the Pardo Palace, where the president is staying, and where he held a 35-minute meeting with Spanish Prime Minister Felipe Gonzalez. National security adviser Robert C. McFarlane said the two leaders discussed broad East-West issues and avoided controversy in their opening session.

But Reagan and Gonzalez are expected to get down to business Tuesday and tackle the touchy issues that are likely to dominate this state visit.

The most troublesome is Gonzalez's desire to reduce the size of the U.S. military contingent here, 12,540 troops stationed at four separate bases. White House spokesman Larry Speakes said today that Reagan "will listen" to what Gonzalez has to say, but administration officials have consistently argued that the present level of forces is necessary for western security.

Gonzalez, whose Socialist Party was elected in a 1982 landslide, has proposed the troop reductions as an alternative to carrying out his popular campaign promise to support Spain's withdrawal from NATO.

Reagan is anxious to avoid further controversies on his 11-day European trip and does not intend to dispute Gonzalez publicly on this issue. At the same time, Reagan is hopeful of postponing any specific consideration of troop reductions, U.S. officials said.

In addition to raising objections to the size of the U.S. military force, Gonzalez appears determined to press Reagan to accept a peaceful resolution of U.S. differences with Nicaragua. Last week, while attending the economic summit in Bonn, the president imposed economic sanctions against Nicaragua, a move widely criticized by European nations, including Spain, and Canada.

The Nicaraguan situation has captured the attention of the Spanish populace, which feels a cultural affinity with the Nicaraguans.

Spanish sources said today that Nicaraguan President Daniel Ortega might stop off here by mid-week on his return from Moscow and Eastern Europe.

In a local radio interview today before Reagan arrived, Gonzalez characterized U.S. policy on Nicaragua as "contradictory." He said that U.S.-backed rebels, whom Reagan has frequently described as "freedom fighters," instead "without doubt belong to the Somoza regime."

Before his initial meeting this evening with Gonzalez, Reagan posed for pictures at the Pardo Palace and briefly answered a question about his Nicaragua policy.

"Yes, we probably will discuss it," Reagan said. "Maybe our position is misunderstood."

But in initial discussions tonight between Secretary of State George P. Shultz and Spanish Foreign Minister Fernando Moran, the problem appeared to be a policy difference rather than a misunderstanding.

Spain has called for immediate resumption of direct talks between the U.S. and Nicaraguan governments, which the United States broke off in January.

The United States has charged Nicaragua with bad faith in those talks and demanded that it talk directly to the rebels and cut ties with the Soviets and Cuba as a condition of improving relations

Last week, in the face of criticism over the economic sanctions, there were hints from the White House that the president might change his position. However, an administration official said tonight that the United States would still prefer that the Sandinistas negotiate with the rebels.

"We're not saying we won't negotiate directly with Nicaragua if they have something new to say," McFarlane said. "But I wouldn't look for a meeting anytime soon."

The principal U.S. goal during this two-day visit is to avoid the appearance of confrontation and head toward the end of a tiring trip on a high note.

The Spanish agenda for the visit is a full one.

Gonzalez's government would like to see an administration commitment to help lower Spain's trade deficit with the United States, and additional promises to block protectionist measures against Spanish exports.

Spain also desires more participation by its own arms industry in U.S defense contracts.

But Gonzalez has made clear in a number of statements in recent weeks that he expects the talks to focus on Central America and the NATO troop reduction issue.

The U.S. military presence here is based on a 1953 bilateral agreement last renewed, for five years, in 1983. Last October, however, Gonzalez proposed that the troop numbers be reduced as part of a package that would make his change of position on Spain's NATO membership more palatable.

Polls consistently have shown the majority of Spaniards opposed to NATO membership, which the previous government negotiated in 1982. Although Gonzalez campaigned on a pledge of NATO withdrawal, he subsequently became convinced that Spanish membership in the European Community, finally agreed in Brussels this spring, and a good rating with Western banks, would be more difficult if NATO withdrawal were pressed.