Hundreds of riot police fired tear gas to push back a huge crowd from the gates of Zhongnanhai, the Communist Party compound where many leaders live and work, witnesses told Western reporters.
The witnesses also said that at least 30 people were beaten by police outside the Beijing Hotel.
The midafternoon confrontation unfolded after an earlier attempt to move soldiers to the square during the predawn hours had failed.
A main column of about 5,000 unarmed soldiers advancing from the east was blocked at 3 a.m. by an unyielding crowd of about 8,000 people and a hastily assembled barricade of trucks. The soldiers retreated after a brief shoving match with the front lines of the protesters just a few hundred yards east of the square, which has been occupied for the past three weeks by pro-democracy student demonstrators.
The crowd was protecting the students camped in the square, who now number about 5,000, and also trying to prevent destruction of a 30-foot-high "Goddess of Democracy," modeled after the Statue of Liberty, that was erected in the square Tuesday morning.
Protesters broke into applause as the sweaty soldiers, looking tired and humiliated, silently marched back in the direction from which they came. "An enthusiastic send-off!" shouted some in the crowd, made up of both students and ordinary Beijing residents.
A similar scene was repeated on the same main street, Changan Avenue, on the opposite side of the square. An American television crew reported that thousands of people massed around an army truck and several buses near the Minzu Hotel, about two miles west of the square. Although most of the troops appeared to be unarmed, citizens discovered automatic weapons and clubs inside more than one vehicle.
Additional troops, some wearing what appeared to be gas masks, had been advancing behind the vehicles, United Press International reported.
At least two busloads of troops and an officers' jeep made their way slightly closer to the square before being trapped by swarms of protesters, who let the air out of the jeep's tires, surrounded the buses and angrily lectured the troops that they should not use force against the students gathered in the square.
Another group of about 300 soldiers approached the square from the north and was trapped by the crowd in a side street just west of the famous Beijing Hotel, very near the spot where the main column of troops from the east was blocked.
Throughout the evening, foreign eyewitnesses shared information about what was happening, and many foreign correspondents, including a large number of television crews, moved freely through the downtown area. Authorities made virtually no effort to enforce martial-law restrictions and rules against press coverage imposed Thursday, and journalists thus could piece together a fairly broad picture of the night's events.
A young man stood on top of one of the troop buses trapped west of the square and shouted to the crowd: "People, rise up!"
"I support it," said a middle-aged man in blue workers' clothes who stood beside his bicycle, smiling and laughing at the extraordinary scene. "I simply cannot stand to have troops enter the city."
Others in the crowd said they were out in the street because they back the students' demands for freedom and democracy.
There were relatively few political chants during the confrontation. But some in the crowd shouted, "Li Peng, step down!" in a call for the resignation of China's hard-line premier, and one group carried a banner declaring, "Oppose martial law!"
Li's resignation and the lifting of martial law, which Li declared on May 20, have become the two most immediate demands of the student protests. The protests originated in mid-April with demands for freedom of the press, improved treatment of intellectuals and an attack on official corruption.
The retreating soldiers appeared bedraggled and demoralized. The Associated Press quoted one soldier as saying, "If I'm going to die, I want to die on the battlefield, not on Changan Avenue."