The passengers from one car were plucked one by one and transferred to a rescue gondola shortly before dawn, while those in the second car, at the edge of Manhattan, were taken out with a crane.
At least a dozen of the 69 passengers were children or babies who had boarded the tram at the start of rush hour on Tuesday evening.
One boy described the mood in his car as almost festive, with people singing and telling jokes. Police delivered food, water and nappies to the passengers while they waited.
His mother, Robbyn Maier, said her 12-year-old son, Dax, was going to Roosevelt Island to play tennis when he got stuck. She talked to him by mobile phone.
"He's like a trouper through it all," she said. "He's really a little hero."
But she added: "He's not coming this way to tennis anymore."
Of course, there were problems spending that much time in a cable car.
"Well, there was this one kid who peed in a cup," Dax told ABC's Good Morning America.
He said he told himself not to look down while being rescued.
"When I was climbing out the window, I was just a little scared, because one, what if I miss it, two, what if I flip, and I might fall into the river, so I just kept looking up," he told CNN.
Officials were trying to determine what caused the power outage on the Roosevelt Island Tramway, which offers breathtaking views of the city from 250 feet high and is a commuter route for island residents, said Herb Berman, president of the agency that operates the system.
Tramcars on the system can hold about 125 people and stall occasionally, the last time around September's Labour Day holiday, Mr Berman said.
Police said that this time, the main and backup power systems failed.
Lynn Krogh, spokeswoman for New York State Governor George Pataki, said the state Department of Labour would investigate before allowing the service to resume.
About 10,000 people live on Roosevelt Island, which also is accessible by bridge and subway. The island is about two miles long and 800 feet wide.
The tram system, which opened in 1976, is the only commuter cable car system in North America, according to the Roosevelt Island Operating Corporation website.
It has been featured in movies such as Spider-Man, City Slickers and the Sylvester Stallone thriller Nighthawks.
The trams travel 3,100 feet in about five minutes at an average speed of 16mph.