No injuries were reported, either on the aircraft or the ground.
There was no immediate indication that the engine failed because of a bird strike, which caused a US Airways plane to make a crash landing in the Hudson River in January.
Jim Peters, a spokesman for the Federal Aviation Administration, said the crew reported hearing a loud noise just after takeoff. He said the noise was an indication that the engine on the right wing of the McDonnell Douglas 80 had failed.
Metal fragments apparently from the engine reportedly landed on the rooftop of a warehouse in the College Point section of Queens, CBS station WCBS-TV reported.
"We heard a very, very loud sonic boom or explosion, followed immediately thereafter of about 30 to 45 seconds of debris raining down - everybody was quite alarmed. We immediately suspected it was a problem with a plane," one witness at the warehouse told WCBS.
American Flight 309 had left New York's LaGuardia Airport at 8:15 a.m. After the pilot reported engine problems, the plane was quickly diverted to Kennedy Airport, where it landed safely. Kennedy is about 12 miles southeast of LaGuardia.
The plane, with 88 passengers and a crew of five, landed at JFK at 8:36 a.m. - 21 minutes after takeoff. The pilot taxied to a gate and the aircraft was inspected. Pieces of metal were found embedded in the fuselage of the aircraft, Peters said.
The plane had flown over the city's borough of Queens, where people in the neighborhood reported hearing a loud noise. Investigators later found about four dozen pieces of metal that had crashed onto a rooftop.
Police and aviation investigators photographed the debris, which was taken to LaGuardia for inspection. The bulk of the engine remained attached to the plane's wing, Peters said.
On Jan. 15, Flight 1549 ditched into the Hudson after it hit a flock of Canada geese less than 2 minutes after taking off from LaGuardia. All 155 people aboard that aircraft survived.
In Wednesday's incident, the plane took off from LaGuardia in the northeast corner of Queens, turned north over Long Island Sound and made it as far as Stamford, Connecticut, before turning south again and heading for Kennedy Airport.
The Federal Aviation Administration was investigating the cause of the engine failure.
American Airlines spokeswoman Andrea Huguely said the passengers and crew were all unharmed. She did not know the age of the MD80 plane or whether it had experienced any major problems in the past.