TOKYO, NOV. 27 -- Prime Minister Noboru Takeshita said today that Japan must open its markets if it wants to continue to benefit from free world trade.

"There may be times when we have to ask the people to forbear and endure," Takeshita told the opening session of Japan's Diet, or parliament. "However, Japan is one of the countries that has benefited the most from free trade, and I hope the people will understand these reforms are needed ... to continue to develop."

Takeshita's speech was his first major policy address since he was elected prime minister Nov. 6.

Interrupted by shouts from opposition party members and applause from his own party, Takeshita gave a vague outline of the policies he hopes to pursue in his two years in office but avoided concrete promises.

"I believe Japan must work actively on improving market access," Takeshita said.

A week ago, Foreign Minister Sosuke Uno said Japan would not open its public construction market, worth $200 billion in the next decade, to foreign companies.

In his address, Takeshita also said he would attempt "to make a positive contribution through nonmilitary means" to "secure free and safe navigation in the Persian Gulf."

The government has discussed increasing its share of the costs of maintaining U.S. bases in Japan to ease the burden of U.S. expenditures in the gulf, but the money is not included in the 1988 budget.

Takeshita emphasized the importance of good relations with the United States.

"Relations with the United States are the cornerstone of Japanese foreign policy," he said, adding that he plans to visit Washington "as soon as possible to hold candid exchanges of views with President Reagan.