Just when it seemed time to break out the victory balloons at City Hall, a new poll has cast uncertainty over Mayor Edward I. Koch's prospects of handily winning the Democratic gubernatorial nomination next week, and has given new hope to his opponent, Lt. Gov. Mario Cuomo.

Koch, who has enjoyed landslide leads in other recent polls, held a statistically insignificant margin of one point in the latest statewide survey, conducted for Gannett Newspapers by pollster Gordon Black.

The new tally marred what was to have been a big day for Koch -- his endorsement by retiring Gov. Hugh Carey. And it brought confusion and controversy to the final campaign week in a state that is accustomed to politics that way.

"Somebody is going to have egg on his face," said Koch, celebrating the good news/bad news day with a mix of metaphors, "and I believe I have the wind at my back."

Cuomo reacted with typical caution.

"At the very least, what you have to concede is that there's a race on," he said. "I don't want to be considered a favorite, God forbid."

But pollster Black says he now thinks Cuomo is favored to win. His poll showed Cuomo with an eight-point lead among Democrats who said they were certain to vote, and a 21-point lead among those who expressed "great interest" in the election.

Cuomo is considered more liberal than Koch. Liberals tend to be the most active and enthusiastic participants in Democratic primaries, while conservatives are more active in Republican primaries.

The Gannett poll contributed more confusion than light, however, because other polls earlier this month showed Koch holding a large lead. A New York Post poll showed him ahead by 22 percentage points; an AP/NBC poll had him leading by 11.

In a carefully planned confluence of events, Carey and Koch conducted their joint news conference at the same time Gannett officials were announcing their poll results.

"I believe Ed Koch will provide the most capable and effective leadership," Carey said.

Carey once had high praise for Cuomo, but his admiration waned after Cuomo indicated that he might challenge Carey if Carey sought reelection. Yesterday, Carey said Cuomo had been an "able and adequate lieutenant governor."

Koch has rolled up an impressive array of endorsements in his drive for the gubernatorial nomination. Although Cuomo's strength is in upstate New York rather than New York City and its suburbs, Koch has been endorsed by a number of upstate newspapers, including Gannett's flagship papers in Rochester. He also has been endorsed by the New York Daily News and the New York Post.

All the polls show that Koch runs strongest in suburban Nassau, Suffolk and Westchester counties. His lead is much narrower in New York City itself, which worries his strategists.

Koch's campaign mastermind, media expert David Garth, argues that the relatively narrow margin in New York City is largely because many voters want to keep the mayor in City Hall. He has produced a new television spot to counter this by emphasizing how much a sympathetic governor can help the city.

Yesterday, in a taped television debate with Cuomo, the mayor made the same point."Some of them don't want me to go to Albany ," he said. "I'm saying to them, 'Please let me go.' "

Cuomo tried to turn the theme to his advantage. He recalled how Koch had in past years said that Cuomo would make a fine governor and responded: "Governor Cuomo and Mayor Koch will be an excellent team."

Garth has also started airing a couple of television ads that attack Cuomo's competence and record.

One features an announcer who challenges the viewer to name one thing that Cuomo has accomplished as lieutenant governor in the next 20 seconds -- after which the camera focuses on a stopwatch that ticks silently as each second passes. The other raises an old scandal in which one of Cuomo's aides, who has since gone to jail for it, put fictitious employes on the state payroll.

In the final week of the campaign, Cuomo will try make the contrast between his positions on a number of social issues and those of Koch even sharper, according to his campaign manager, William Haddad.

Pollster Patrick Caddell has told Cuomo that as many as half of those who say they favor Koch would vote for Cuomo if they knew better what he stands for, according to a senior campaign adviser.

To this end, Cuomo will spend the final week attacking Koch for being willing to see Social Security cost-of-living increases reduced, his willingness to see other social spending programs cut back, and his early coziness with President Reagan and conservative New York Republican Sen. Alphonse D'Amato.

Koch's aides criticized the latest Gannett poll on the grounds that it was weighted too heavily to upstate voters. The poll showed that Cuomo led Koch by 9 percent upstate while Koch led Cuomo by 14 percent in the suburbs and by only 3 percent in New York City. Last June, a Gannett poll showed that Koch had an 8 percent lead over Cuomo, with a whopping 30 percent margin in the suburbs and a 12 percent lead in the city.

The Gannett pollster attributed what he said was Koch's decline in the city to inroads that Cuomo has made among liberal Jewish voters; Koch's overall support among Jews has declined from 34 percent to 21 percent in the Gannett poll. Another factor, he said, is that Cuomo now leads Koch among black voters by 53 percent to 36 percent.

Cuomo said that since word of the Gannett poll has become known, he has spent much of the day receiving phone calls from new-found well-wishers.

"The world is filled with investors," he said. "The world is suddenly filled with people of high principle who discover their principles when the polls come in. We have the money to stay in television now. We are in very good shape."