HARTFORD — Visiting New Haven on the eve of the Tuesday’s gubernatorial election, Dan Malloy said he would be giving a victory speech the next day. Tom Foley, stumping in East Hartford, said the same. Both of them were right.

[ydn-legacy-photo-inline id=”5686″ ]

Foley, the Republican nominee and former ambassador to Ireland, and Malloy, the Democratic candidate and former mayor of Stamford, both claimed victory in Connecticut’s election early Wednesday morning. With 90 percent of precincts reporting, Foley led Malloy by almost 10,000 votes, or one percent of the vote. The result remains uncertain as ballot counting is expected to continue through at least Wednesday morning in the Democratic strongholds of Bridgeport, Hartford, New Haven and Stamford. No vote totals have been reported from Bridgeport, where voting was extended by two hours and ballots are being counted by hand after a shortage of thousands of ballots caused hours-long backlogs at polling places. The Bridgeport Registrar of Voters had ordered 21,000 ballots in anticipation of Election Day with about 69,000 registered voters in the city.

Appearing at 1 a.m. in the still-packed Hartford Society Room, Malloy said based on his campaign’s examination of returns, he believed that he will be the state’s first Democratic governor in 20 years.

“We started this journey a long time ago knowing that Connecticut is hurting,” he said, “Tonight is a testament, this is the first step, this is the beginning [of the recovery].”

At the same time, Foley took the stage before an equally energetic crowd at the Greenwich Hyatt Regency and said he too is sure he has won.

“It’s very close and we are quite confident that we will win,” he said to raucous applause.

In a phone interview with the News shortly after midnight Wednesday, Foley said he could not foresee how any results from the precincts still to report could turn the outcome against him.

“We’re very confident of victory,” Foley said at the time. “In the worst-case scenario, Bridgeport could go against us by 14,000 votes, but by our latest data we’re ahead by 41,000.”

After Malloy held convincing leads in numerous October polls, Foley surged in the final days of the campaign, Quinnipiac Poll Director Maurice Carroll said, one of a just handful of state Republicans to do so.

“It’s still possible that if Bridgeport’s turnout is strong enough, Malloy can still win, but it’s very unpredictable right now,” he said early Wednesday.

A Nov. 1 Quinnipiac University poll put Foley ahead three points — a statistical tie and within the margin of error.

Malloy was a known quantity in the state, having lost a 2006 Democratic gubernatorial primary to New Haven mayor John DeStefano, Jr. In contrast, Foley was relatively new to Connecticut politics — previously he founded and ran the National Textile Group, a private investment company based in Macon, Georgia.

At the victory party at Terminal 110 in Long Wharf hosted by the campaign of Rep. Rosa DeLauro, DeStefano said he was hopeful that Malloy could pull out a victory. Malloy took the New Haven vote by a margin of five to one.

Also in attendance, Carl Goldfield, president of the city’s Board of Aldermen, said he was hopeful that Malloy would prevail because of his experience as a big-city mayor, whereas Foley’s only leadership experience has been as a business executive.

Cyprien Sarteau ’12, the vice president of activism for the Yale College Republicans, said that all of the Republican wins Tuesday, including Foley’s still contested race, were good news.

“Just like in 1994, when the public sent a message to Clinton, tonight sends a striking message to Obama to move towards the center,” Sarteau said.

Ben Stango ’11, president of the Yale College Democrats, said that the 20 years of Republican governorship had yielded the largest achievement gap in the nation, has forced jobs and business out of the state, and that the state needed a Democrat in office to set the state back on track.

“If Foley wins, our state faces a tough future,” he said. “Connecticut would fall into a position that would take decades to recover from.”

The eventual winner will succeed retiring Gov. M. Jodi Rell, who first took office in 2004.

Alon Harish and James Lu reported from New Haven. Anjali Balakrishna reported from Hartford.