A British construction worker and his Italian colleague have been murdered by terrorists in north-west Nigeria after being taken hostage in May last year.

David Cameron confirmed the death of Chris McManus and Franco Lamolinara – who were working for an Italian construction firm – after he had authorised a rescue mission.

The prime minister said it appeared the two men were murdered by their captors before they could be rescued. The captors posted a video, featuring the men, which warned that they would be killed.

The attempted rescue was mounted by British special forces in an intelligence-led operation planned in close co-operation with the Nigerian authorities, well-placed Whitehall sources said.

A unit of the Special Boat Service (SBS) tried to free the men "after a window of opportunity presented itself", said an official familiar with the incident.

"The operation was based on good intelligence – the location was right," a source added. The SBS team was told to go in when it appeared that Chris McManus and Franco Lamolinara were in imminent danger.

"That was the imperative which drove the operation," the Whitehall sources said. They described the men's captors as among the "nastiest al-Qaida-affiliated terrorists there are".

Officials said the operation was planned in advance in the knowledge that the rescuers had to move quickly when intelligence pointed to an opportunity to free the men. But it was clear any attempt to free them was going to be risky.

Units of the SBS and the Special Air Service – the SAS – are specifically trained to undertake counter-terrorist operations.

The men may have been held in Sokoto, a city in Nigeria's north-west, according to Associated Press.

There were reports of a house being surrounded by military forces and the sounds of gunfire being heard before an ambulance was called. Security forces had also set up a cordon around the site.

Christopher McManus, the British hostage killed in Nigeria. The photograph has been chosen by the family for use by the media. Photograph: handout

A Nigerian group, know as "al-Qaida in the land beyond the Sahil", claimed in December that it had captured McManus. The group released a video to Nouakchott News Agency showing a blindfolded and bearded man in an orange vest. Three men in dark clothing stood behind him armed with rifles and a machete.

The hostage pictured in the video reportedly asked the British government to respond to the demands of the group in order to spare his life. He also asked for people in Britain to pressure the government to answer the demands of the group so he could return to his family.

In a statement, Cameron said: "Our immediate thoughts must be with Chris and Franco's families, and we offer them our sincerest condolences. Both families have endured a terrible ordeal, and this is a devastating moment for all of them."

McManus, a contract worker for the construction company B Stabilini, was kidnapped by gunmen last year. Raiders stormed his apartment in Birnin-Kebbi, in the north-west of the country, and captured him along with Lamolinara. A German colleague managed to escape by scaling a wall but a Nigerian engineer was shot and wounded in the raid.

Cameron said that earlier on Thursday he authorised British involvement in the rescue of the two hostages after "credible information" was received about their location, but early indications suggested they had been killed before they could be rescued.

The prime minister said: "After months of not knowing where they were being held, we received credible information about their location. A window of opportunity arose to secure their release.

"We also had reason to believe that their lives were under imminent and growing danger. Preparations were made to mount an operation to attempt to rescue Chris and Franco. Together with the Nigerian government, today I authorised it to go ahead, with UK support."

Cameron added that the Foreign Office had been in contact with McManus's family since his capture in May last year. He spoke to them just before Christmas and has conveyed to them the news of his death.

"I want to take this opportunity to thank the Nigerian authorities, and President [Goodluck] Jonathan personally, for all they have done to help find Chris, and combat terrorism. I also want to pay tribute to all those, including UK personnel, who worked so hard to try to bring Chris home safely. I am very sorry that this ended so tragically.

"I ask that the media respect the family's privacy and allow them time to come to terms with their loss. Terrorism and appalling crimes such as these are a scourge on our world. No one should be in any doubt about our determination to fight and to defeat them."

The prime minister visited Nigeria in July last year, two months after the men were taken hostage, and met President Jonathan in Lagos. In his statement on Thursday evening he said he had been discussing the matter with the Nigerian authorities since the kidnapping in May.

McManus's parents spoke of their devastation at his death. In a statement issued by the Foreign Office, they said: "Our son Chris was abducted in northern Nigeria on 12 May last year. As a family, we are of course devastated by the news of Chris's death which we received earlier today. During this ordeal we have relied heavily on the support of our family and friends which has never waned and has enabled us to get through the most difficult of times."

They thanked the British and Nigerian authorities for attempting to launch a rescue mission. "We are also aware of the many people who were working to try and have Chris returned to our family, and his girlfriend. We would like to thank all of them for their efforts," they said.

"We knew Chris was in an extremely dangerous situation. However we knew that everything that could be done was being done."

McManus's parents paid tribute to his Italian colleague and asked for their privacy to be respected. "Our thoughts are also of course with the loved ones of Chris's colleague Franco Lamolinara who are also coming to terms with this truly sad news.

"We now need time to grieve and come to terms with our loss. We would therefore be grateful if you would respect our privacy at this most difficult of times."

There have been a number of foreigners kidnapped while working in Nigeria in recent years.

In September 2008 two Britons were held by the Movement for the Emancipation of Niger Delta. A Scottish oil worker was abducted and his guard killed in April 2009, in the Rivers state capital, Port Harcourt. Three Britons and a Colombian were kidnapped in January 2010 and in November of the same year, four men from the US, Canada and France were taken seven and half miles offshore on the Okoro field.

Cameron called the Italian prime minister, Mario Monti, to inform him of the "tragic conclusion" of the operation, a statement from the Italian government said.

Ed Miliband, the Labour leader, said: "Our hearts go out to the families of Chris McManus and Franco Lamolinara. Their murder is a horrific event. I condemn unreservedly the callous cruelty of their kidnappers and we pay tribute to those who risked their lives in attempting to rescue them."

A British construction worker and his Italian colleague have been murdered by terrorists in Nigeria as UK special forces, supported by the Nigerian army, attempted to rescue them. Find out how it happened ...