Anger mingled with fear and prayer yesterday as, for the fourth time in less than 20 years, Americans learned that gunshots had been fired at their president on the streets of a large city.

As reports filled the airwaves throughout the afternoon, first of the attack itself, then that the president had been wounded and that his press secretary, James S. Brady, was in grave condition, powerful figures of government and ordinary citizens did as duty and instinct demanded.

In Texas, Vice President Bush hurried to Carswell Air Force Base on the west side of Fort Worth shortly after getting word of the shooting and flew back to Washington and the uncertain situation facing him and the rest of the government.

In New York, trading on the New York and American stock exchanges was stopped shortly after 3:15 p.m. when word reached Wall Street that the president had been hit in the gunfire outside the Washington Hilton Hotel.

In Lincoln, Neb., where he was to dance last night with the Joffrey II Ballet, Ronald Prescott Reagan, the president's 23-year-old son, was whisked out of a hotel shortly after 3 p.m. and taken to the airport where he boarded a charter flight to the nation's capital.

In Washington, Majority Leader Howard H. Baker Jr. (R-Tenn.) recessed the Senate while he and colleagues gathered to express shock, disgust and sorrow at what had happened.

And in cities as different as Boston and Oklahoma City, prayer services were announced for Reagan and the other victims of the attack.

Sen. Edward M. Kennedy (D-Mass.), two of whose brother were killed by gun-wielding assassins, was one of the first senators to react after receiving word of the shooting but before he knew that Reagan had been hit.

Taking to the Senate floor before the recess, Kennedy recalled the deaths of his brothers, President John F. Kennedy and Sen. Robert F. Kennedy, and said:

"Violence and hatred are alien to everything that this country is about. It does not bring about a change in policy. It is alien to what is best in our nation. With our prayers for those who have been wounded today must go our resolution to rid our society of violence and to commit ourselves to do everything that we possibly can to eliminate hatred and the causes which contribute to hatred in our society."

In comments off the floor, Sen. Henry M. Jackson (D-Wash.), said, "What can one say? We hope against hope that with the tragedies of the past there won't be another. But there is."

Sen. Alan Cranston (D-Calif.) said he and other senators gathered in the cloakrooms after hearing of the shooting. "It was very, very depressing," he said. "Emotions were under control but were very, very high."

Cranston described a scene of senators gathered around a television set as Sen. Gary Hart (D-Colo.) turned the channel selector seeking the latest news. "He [Hart] winced when they said the alleged assailant came from his state," Cranston said.

Sen. Daniel Patrick Moynihan (D-N.Y.), who was visibly shaken, commented, "How much shooting is going to have to happen before we get rid of those guns?"

Added Sen. Claiborne Pell (D-R.I.), "The general feeling of all of us is one of shock and horror."

Baker recessed the Senate by citing the "gravity" of the situation. On the other side of Capitol Hill, House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.) issued a terse statement saying, "I am shocked that this happened and I join all Americans in praying for the president and the others who were injured."

For some, the assassination attempt meant a flurry of activity. Secretary of State Alexander M. Haig Jr. announced at the White House that he and other key Cabinet members were in the Situation Room and that U.S. military forces had not been placed at any higher state of alert as a result of the shooting.

"As of now, I am in control here in the White House until the vice president returns here," Haig said.

Others, with no official duties to perform, were stunned by the afternoon's events and had a variety of reactions:

Former president Jimmy Carter withheld immediate comment on the shooting, but his office in Atlanta issued a brief statement. "President Carter is anxiously awaiting further word on President Reagan's condition and that of the other wounded. He and Mrs. Carter join the entire nation in prayer for the well-being of all those wounded and for their families."

Cardinal Terence Cooke of New York called for prayers "for the swift recovery of President Reagan and his associates" and invited the public to join in prayers at a late afternoon mass in St. Patrick Cathedral.

Across the country, both Democratic and Republican politicians expressed shock and disbelief at the shooting. Detroit Mayor Coleman Young said the shooting was "a chilling reminder that it is impossible to assure the safety of a public figure." Said Michigan Gov. William Miliken: "It's incredible that this type of thing could happen once again."

The president's former colleagues in the movie industry postponed last night's scheduled Academy Award ceremonies until tonight. Reagan had videotaped remarks to be shown during the program. Officials said it remained possible the videotape would be shown when the rescheduled ceremony is conducted.

Benjamin Hooks, executive director of the National Association for the Advancement of Colored People, issued a statement saying he was "shocked and heartsick at the brutal attempted assassination of President Reagan and the wanton state of violence that is reaching epidemic proportions in America today."

In Houston, former Texas governor John B. Connally, who was wounded in the 1963 shooting that killed President Kennedy, said he was "profoundly shocked and saddened" and grieved "not only about the president, but about Jim Brady, the Secret Service agent and the policeman who were also wounded." Brady was Connally's press secretary during the 1980 Republican primaries before joining the Reagan campaign for the general election.

In Centralia, Ill., a neighbor said Brady's parents, Harold and Dorothy Brady, were "doing fine." But, added, Kay Warner, "Mr. Brady has a heart condition and they're keeping a close watch on him."

Members of the president's family, meanwhile, were in seclusion. Maureen Reagan, his 39-year-old actress daughter, was described as "in a complete state of shock" in Los Angeles. Michael Reagan, 35, the president's eldest son, remained in his suburban Sherman Oaks, Calif., home, which was cordoned off by Secret Service agents.

As word of the assassination attempt spread, various public bodies in the country reacted. The Texas Legislature unanimously adopted a resolution condemning the shooting. The Iowa House stood for a moment of prayer. In Philadelphia, there was a moment of silence before the start of the NCAA basketball consolation game between Virginia and LSU. After an early evening meeting, NCAA officials decided not to cancel the championship game between North Carolina and Indiana.

Around Dixon and Tampico, the western Illinois towns where Reagan grew up, there was as much disbelief at the sudden act of violence as anywhere. "He hasn't been president long enough for anyone to get that angry," said Shirley Miller Roundy of Dixon.

And in Los Angeles, comedian Bob Hope recalled being with Reagan during the presidential campaign when Reagan showed his longtime friend a bullet-proof jacket that had been built into his raincoat.

"I wish he'd been wearing that today," Hope said.