President Reagan gave Israel a sternly worded warning yesterday that the "escalating violence" around Beirut must stop if there is to be a diplomatic solution to the Lebanon crisis. But Israeli sources said later they were reassured that Israel and the United States still share the goal of moving Palestinian guerrillas out of Lebanon.

Reagan also angrily rejected as "a propagandistic exercise" Soviet President Leonid I. Brezhnev's charge that the United States has failed to restrain Israel in Lebanon. He said Moscow's action in making public confidential correspondence "casts doubt upon Soviet motives regarding the Lebanon crisis."

The president, who said Sunday that he was losing patience with the repeated breakdown of the cease-fires around Beirut, met for 20 minutes yesterday with Israeli Foreign Minister Yitzhak Shamir. Later the White House issued a statement containing some of the toughest-sounding language used by the Reagan administration since the Israeli invasion of Lebanon began on June 6.

It said Reagan stressed "the need for a complete end by all parties to the hostilities in and around Beirut" as "a prerequisite" for the president's special envoy, Philip C. Habib, "to pursue his urgent work" of trying to negotiate the removal of Palestine Liberation Organization fighters from the city and then from Lebanon.

"The world can no longer accept a situation of constantly escalating violence," the statement said. It added, in reference to Israeli efforts to keep pressure on the PLO forces in West Beirut by cutting off water and supplies, that Reagan emphasized "the need to maintain essential services and to assure adequate supplies of food and medicine."

Reagan appeared grim at the outset and was armed with notes from which he reportedly read while talking with Shamir. However, Israeli sources accompanying Shamir said afterward that they regarded the atmosphere at the White House, and in Shamir's later meetings with Secretary of State George P. Shultz and Defense Secretary Caspar W. Weinberger, as "friendly."

These sources acknowledged that "tactical differences" remain between the two governments about how to deal with the Lebanon situation, and they said U.S. officials were firm in stating their concern that continued fighting could endanger Habib's chances for success.

However, the sources continued, Shamir came away reassured that there has been no shift in U.S. policy since Shultz replaced Alexander M. Haig Jr. Specifically, they contended, the United States and Israel continue to seek, as their primary goals, the removal of the PLO from Lebanon, the strengthening of the Lebanese central government and the withdrawal of all foreign forces from Lebanon.

But, while these have been U.S. goals since Israeli forces advanced to the outskirts of Beirut six weeks ago, the Reagan administration has been seeking to achieve them in a way that avoids the bloodshed caused by Israeli shelling and bombing of the city. As one Israeli source conceded, "The U.S. emphasis is on Habib and his negotiations, while we believe that without the military option, the negotiations can't succeed."

The Israeli position was underscored publicly by Shamir, who told reporters: "We prefer to have a cease-fire all the time . . . . But we are convinced that the PLO will not leave Beirut and Lebanon, unless they will be convinced that they have only one choice before them: to leave by negotiations or by other means."

He added, "There is not any deadline for PLO withdrawal , but it is our position that it cannot last forever." In private, the Israeli sources said they had agreed to give Habib more time, but they stressed that it is "not unlimited."

U.S. officials, while refusing to characterize Reagan's statement as a warning, called attention to those portions insisting that the cease-fire be maintained and that humanitarian considerations be observed. State Department spokesman Alan Romberg said, "Obviously continuation of the fighting makes it extraordinarily difficult for Ambassador Habib to conduct his mission, and that is a matter of great concern to us."

Reagan, who left for Iowa after the meeting with Shamir, had a statement issued responding to the Soviet action in making public a letter sent by Brezhnev over the weekend urging him to "end the extermination" of the people in Beirut.

It rejected "the implication that the U.S. is not doing all that it can to bring about a peaceful solution." It added, "We regret the Soviet decision, once again, to publicize portions of confidential correspondence between the two presidents. Such a propagandistic exercise casts doubs upon Soviet motives regarding the Lebanon crisis."