The MP Tobias Ellwood held back tears as he told the Westminster Bridge attack inquest how he fought to save the life of PC Keith Palmer, persisting with CPR despite fears of a second incident and only giving up when ordered to do so by a doctor.

In powerful testimony at the Old Bailey on Monday, the Conservative MP and former soldier spoke about the minutes after the attack, drawing a comparison with his own brother’s death in a 2002 terrorist bombing in Indonesia.

He told the inquest: “My brother was killed in a secondary attack in Bali … so I was very aware of that. I was concerned about what would happen if things were to ratchet up, but my immediate concern was that we had somebody who was clearly badly bleeding and needed assistance.”

Ellwood said he persisted with efforts to perform CPR on Palmer until a doctor at the scene told him there was nothing more that could be done.

“I looked at him and said: ‘You’re going to have to tell me to stop. You must order me to stop – make that decision,’” the MP said. According to Ellwood, the medic responded: “Sir, you have done your best but you do need to stop.”

Becoming emotional as he recalled the dramatic events when doctors opened Palmer’s chest, he said: “Forgive me, it’s sometimes easier to do the helping rather than to talk about it afterwards.”

When the medics left to help other victims, Ellwood said he and another officer were left with Palmer’s body. “There was an eerie silence at the Palace of Westminster ... We both tidied up the body as best we could. We closed the eyes and I said: ‘I am sorry,’” Ellwood said.

“It was very, very silent, it was a very strange end to a very traumatic four or five minutes, to suddenly be left completely alone with just one other person.”

Khalid Masood, 52, killed Kurt Cochran, 54, Leslie Rhodes, 75, Aysha Frade, 44, and Andreea Cristea, 31, when he ploughed an SUV into pedestrians on Westminster Bridge before stabbing Palmer to death at the gates to the Palace of Westminster.

Ellwood spoke of arriving on the scene to shouts of “Go, go, go” and “go back, go back”. He saw Palmer on the ground and went over to help, as he was medically trained. His first observation was the number of armed police officers who were pointing their weapons towards Carriage Gates in Westminster.

The MP said Palmer was pale and had lost a lot of blood, although he had a pulse. “Unfortunately, as is the case in these situations, eventually his heart stopped as did his breathing, and that’s when I commenced CPR,” he said.

Ellwood carried out chest compressions while another man carried out mouth to mouth until a paramedic team arrived. “There was a sense of relief for me … I could now share the burden with professionals.”

When the helicopter emergency medical service doctor arrived, Ellwood said, they were asked to move Palmer to an area where they would have more space around them. The emergency medical team decided to work on Palmer there and then, even taking surgical action, but it was not possible to revive him.

The politician also talked about security around the Palace of Westminster, saying it could have been better. He said he had considered the issue since then and he had felt a sense of vulnerability.

He said there had been a significant change in security since the incident and there was now a more substantial presence. “I visited the spot and was pleased to see the level of security now in place. I am not sure we could do much more,” he said.

“I believe we should be protected but must continue with transparency … The more we become a tower of protection then it changes the face of what parliament is about and the terrorist may die on the day but they win,” he said.

Ellwood said he would have been behind Masood as he launched the attack if he had taken his usual route to parliament. “I know I would have stepped forward and I regret not having the opportunity to do so,” he said.

Dr Antony Hudson, from London’s helicopter emergency medical service, also spoke at the inquest. He said that when he arrived at the scene two patients were in traumatic cardiac arrest: Palmer and the attacker Masood, who had been shot by police.

The doctor explained that patients with stab wounds had a better chance of being resuscitated, so he went towards the officer. He gave Palmer a blood transfusion and operated on his open chest as he lay on the ground, but said he could not be saved.