NEW YORK (AP) _ East Side, West Side, and all around the town, Mikhail Gorbachev sampled the sights of this ''unique city,'' twice stepping out of his limousine to the delight of cheering New Yorkers and the dismay of his security detail.

''Nobody booed at all; everybody cheered,'' said Mark Johansen, 30, after the Soviet president and his wife, Raisa, emerged from their motorcade briefly Wednesday in the middle of Broadway in Manhattan's Theater District.

The Gorbachevs watched dusk spread over the twinkling city from the top of the city's tallest building, the 110-story World Trade Center, then sped uptown to the gaudy lights of Times Square as crowds lining the streets cheered and applauded.

''The crowd was just going hysterical,'' said Joe Crawford, a 17-year-old high school student from Connecticut. ''It was really exciting that he stopped here in front of us.''

The Gorbachevs did it again minutes later uptown, when they greeted onlookers outside that consumer cornucopia - Bloomingdale's department store.

But after only one day of diplomacy and sightseeing, they cut their visit short. Soviet Foreign Minister Eduard A. Shevardnadze announced late Wednesday that the Soviet leader would leave New York a day early because of a catastrophic earthquake in three Soviet republics.

The cancelled plans today included a Soviet trade show and a stroll through Central Park and the Metropolitan Museum of Art with his wife.

The Gorbachevs - and their 45-car motorcade - toured Manhattan on Wednesday after he addressed the United Nations General Assembly and attended a luncheon with President Reagan and Vice President George Bush on Governors Island.

Following a short ferry voyage to Manhattan, the Communist Party leader sped through the heart of U.S. capitalism to Wall Street and the World Trade Center.

The motorcade did not cause the massive gridlock feared by officials and commuters, and provided normally unimpressed New Yorkers and tourists with a novel diversion.

''I just saw Gorbachev,'' a messenger said after the motorcade passed. ''I'll never wash my eyes again.''

For Gorbachev, known for his Western-style politicking, the feeling of excitement seemed mutual.

''We're very pleased by the fact that thousands of New Yorkers have come out to see us,'' Gorbachev said on the building's observation deck. ''We saw their faces, we saw their eyes, their friendliness. ...

''Believe me, we appreciate this. We are grateful for this warm hospitality.''

Atop the Twin Towers, the Gorbachevs received gifts - a Steuben crystal sculpture of a bald eagle for Gorbachev and a bouquet of roses and a silver bowel from Tiffany's for Mrs. Gorbachev.

The Soviet president said it was ''nice to be here as a tourist almost half a mile over New York.''

''What I particularly liked about the city, is this is a unique city, a city of splendid identity and architecture,'' Gorbachev said. ''You see different areas in the city that have their own special identity.''

As the sun set, the Gorbachevs gazed out the windows.

''Just beautiful. Just beautiful,'' Mrs. Gorbachev said.

When the Empire State Building was pointed out, her husband quipped that he had heard of it.

Then they headed uptown.

Night had fallen by the time they reached Times Square and its dazzling illuminated signs. ''Welcome, General Secretary Gorbachev,'' read one. ''Frisky Wives II,'' proclaimed a movie theater marquee.

The Gorbachevs' stop at 50th Street and Broadway lasted less than a minute, much to the relief of jumpy guards who quickly surrounded him. The Soviet first couple waved and raised locked hands over their heads, and the crowd went wild.

''I waved to him, he waved back with a smile,'' said a tickled Tina Russo, 16, of New Jersey.

''He surprised us,'' said Chief of Department Robert J. Johnson, the city's highest ranking uniformed police officer. When the Gorbachevs' limo stopped, the advance part of his police escort continued along Broadway, but made a quick U-turn and returned when they realized what had happened.

The motorcade continued uptown and east to Bloomie's and the Gorbachevs' second impromptu stop before arriving at the Soviet Mission.

While her husband gave his U.N. speech and met with Reagan and Bush, Mrs. Gorbachev had lunch with Nancy Reagan and Barbara Bush at U.N. Secretary- General Javier Perez de Cuellar's East Side residence.

The stylish Soviet first lady later went to Estee Lauder Inc.'s offices near Central Park, where she sampled perfume and examined the company's selection of cosmetics.

''I am happy to be in the city you call the Big Apple,'' she said at the luncheon, speaking through an interpreter.