The U.N. Security Council formally authorized Secretary General Javier Perez de Cuellar yesterday to visit Iran and Iraq next week to discuss an end to their 7-year-long war and asked the two countries for a temporary truce to facilitate his trip.

The action raised hopes that the renewed escalation of the Persian Gulf war, touched off by resumed Iraqi attacks on Iranian tankers and oil facilities last Saturday, might be halted and that Iran will be enticed into peace talks.

The U.N. secretary general said the 15-nation Security Council had told him to discuss with the Iranians only the implementation of its July 20 resolution, which demands an end to all hostilities; withdrawal of forces to internationally recognized borders, and a negotiated settlement.

Iraq has said it will accept the resolution if Iran does, but Tehran has avoided any clear response. Perez de Cuellar said the Iranians had told him in recent discussions they are ready "to discuss with me the implementation of Resolution 598."

The Security Council's president, Ambassador James Gbeho of Ghana, told reporters that Perez de Cuellar will seek "a definitive and unambiguous response" from the Iranians. The United States has been demanding an end to Iranian procrastination and warned that it will press for a mandatory U.N. arms embargo of Iran unless it accepts the U.N. resolution.

Iranian officials have been demanding a U.N. denunciation of Iraq for starting the war as one condition for Tehran's compliance.

Gbeho later met with representatives from Iran and Iraq to discuss dates for Perez de Cuellar's trip and formally request a temporary cease-fire during his mission.

Iran had already extended an invitation to the U.N. secretary general to visit Tehran starting Thursday. He said yesterday he hopes to go "perhaps the middle or end of next week" and to return to New York by Sept. 16 or 17.

Ambassador Vernon A. Walters, the chief U.S. delegate to the United Nations, said he was "very satisfied" the council had unanimously approved the trip and hopes the United Nations is "at the first steps of bringing this terrible cruel war to an end."

There is no indication whether Iran or Iraq will agree to the Security Council request for even a temporary cease-fire while Perez de Cuellar is in the gulf.

A diplomatic source close to the Iraqi government said he thinks that it is possible Iraq will agree to "a very temporary, limited" truce "in terms of days" to provide a better atmosphere for Perez de Cuellar's trip. But he said he doubts Iraq will agree to halt its gulf attacks for much longer unless Iran accepts a comprehensive cease-fire.

Iraq's formal response to the temporary truce proposal will probably be made known this weekend, he said.

The Reagan administration has publicly deplored the resumption of the Iraqi attacks on Iranian oil facilities and tankers and formally asked Baghdad last Saturday to halt them. However, Iraq replied that it regarded the U.S. request as "regrettable and astonishing" and would continue the raids until Iran accepts a total cease-fire.

Yesterday, Iraq's ambassador here, Nizar Hamdoon, told Washington Post editors and reporters that the administration has put no serious pressure on his government to end its gulf attacks and that he thinks that the attacks have had a positive effect on diplomatic developments.

"Practically, there was more activity at the U.N. Security Council this week than the last three of four weeks," he said. "This proves our point -- whenever there are hostilities or an escalation, people get more interested."