KINGSTON - A would-be hijacker surrendered to authorities on Monday after agreeing to free the last of more than 180 hostages he seized hours earlier aboard a Canadian charter jet in Montego Bay, Jamaica.

The suspect, described as a troubled young man, surrendered peacefully to heavily armed police and soldiers who stormed the CanJet plane he had commandeered at Sangster International Airport in the Caribbean nation's prime tourist resort, authorities said.

Identified by police as Stephen Fray, a Montego Bay resident who is about 20 years old and believed to have been armed with a handgun, he had demanded to be flown to Cuba after breaching security about 10 p.m. on Sunday (11 p.m. EDT) to force his way aboard the CanJet charter.

A shot was fired as the hostage drama unfolded, but no one was wounded, a senior police official said.

CanJet said the incident aboard Flight 918, involving a Boeing 737-800 aircraft with 182 passengers and crew, occurred after it made a scheduled landing in Montego Bay en route from Halifax, Nova Scotia.

It came as Canadian Prime Minister Stephen Harper was in Jamaica on a previously scheduled visit following his attendance at the Summit of the Americas in Trinidad and Tobago over the weekend.

Fray initially freed two crew members and all 174 passengers from the plane as it sat on a tarmac at Sangster, which Jamaican Prime Minister Bruce Golding said had been privatized and therefore was responsible for its own security.

After hours of tense negotiations, personally overseen by Golding and his national security minister, Dwight Nelson, Fray agreed to free his six remaining crew-member hostages, according to Jamaican Information Minister Daryl Vaz.

CUBA OR EUROPE?

This is the case of a troubled young man, Vaz told CNN, adding, He definitely has had some mental challenges.

Originally, his demands were to be flown to Cuba because the flight actually was going to Cuba and then back to Halifax. That really was his demand, Vaz said.

He later said that Fray had an apparent change of heart about flying to communist Cuba and changed his request to Europe.

Asked about a possible link between the Canadian prime minister's visit to Jamaica and the bungled act of air piracy, Harper's press secretary declined to speculate.

But Vaz stressed in his comments to reporters that Fray's actions represented an isolated case in the Caribbean nation, which is heavily dependent on tourism.

All passengers aboard Flight 918 were Canadian, according to CanJet, which operated the charter on behalf of Transat Tours Canada.

This is not an act of terrorism and should not be seen as such, Vaz said. The military and police were able to take the man into custody in a peaceful manner.

Harper, meanwhile, told a joint news conference with Golding in Montego Bay he was delighted at how the standoff at Sangster ended without any bloodshed.

Today is a day to be truly joyful. It's very rare that we have events like this that end so well, he said.

The Jamaican government said it would compensate passengers for cash or other valuables they forked over to the would-be hijacker, some in an apparent bid to win their safe release.

Some passengers said that they lost money when the hijacker took it from them. Some said that they left their medication on board, but whatever is lost, the government of Jamaica is committed to giving them back everything that they came here with, Vaz told reporters.