Image caption PC Keith Palmer was pronounced dead at 15:15 on the day of the attack

There were no armed officers at the entrance to parliament for almost an hour before PC Keith Palmer was stabbed, an inquest has heard.

PC Palmer was killed by Khalid Masood in New Palace Yard, in last year's Westminster terror attack on 22 March.

One firearms officer was at another entrance due to Prime Minister's Questions, the inquest heard.

Earlier, Tobias Ellwood MP described how he tried to save PC Palmer until he was ordered to stop giving CPR.

Four other people died after Masood drove into them on Westminster Bridge.

The inquest into the deaths of PC Palmer, 48, Kurt Cochran, 54, Leslie Rhodes, 75, Aysha Frade, 44, and Andreea Cristea, 31, is taking place at the Old Bailey in London.

Dominic Adamson, representing PC Palmer's widow Michelle, told the court that firearms officers were only near Carriage Gates for 14 minutes of the 108 minutes before the attack.

PC Lee Ashby, one of the two authorised firearms officers (AFOs) who was on duty in New Palace Yard, had not been near the gate at all before the attack.

"I have responsibility to the Members' Entrance, Carriage Gates and College Green. I can't do all of those areas," he said.

"There were certain days, Wednesday being one of them, where, as a result of Prime Minister's Questions, you were actively encouraged to be next to the Members' Entrance partly because of the number of high-level MPs and Cabinet ministers."

CCTV footage showed officers on a roving patrol were last at Carriage Gates at 13:42, nearly an hour before the attack began to unfold at 14:40.

The inquest heard how armed officers used to be in fixed posts, but this was changed to roving patrols.

PC Ashby said he thought the previous security arrangements had been "better".

"For me, what we had prior to sectors was the better option because I believe you should have a fixed point firearms officer at every entry point," he said.

CCTV footage showed he and his colleague PC Nicholas Sanders moving towards to the area where PC Palmer had collapsed after three shots rang out. They came from a plain-clothed protection officer shooting Masood.

The two officers faced a misconduct investigation that found they should have been near the gates when they were open, but no formal action was taken against them.

Image copyright PA Image caption Mr Ellwood is a former Army officer and is medically trained

Earlier, the inquest heard from Tobias Ellwood who tried to save PC Palmer's life.

Mr Ellwood - Conservative MP for Bournemouth East and a medically-trained former Army officer - told the court he was in a meeting close by when the attack occurred.

He said he heard a crash followed by screams, adding: "These were not screams of pain... these were screams of shock."

After running through crowds of people and hearing shots fired, Mr Ellwood said he saw a number of police officers crouched near Carriage Gate and PC Palmer and Masood on the floor.

The three officers helping PC Palmer told him he was risking his life because of the chance of a secondary attack, but the MP - whose brother died in the Bali attack in 2002 - told the court: "My brother was killed in a secondary attack... 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."

Mr Ellwood said PC Palmer was unconscious, but that he still had a pulse.

But PC Palmer's heart stopped, and Mr Ellwood had to begin chest compressions while someone else gave the officer mouth-to-mouth.

"By this time the whole of Westminster was very silent," he said.

A medical team arrived by helicopter and moved PC Palmer so they could operate on him in the courtyard.

Mr Ellwood had to pause in the witness box, before saying: "Forgive me, it's sometimes easier to do the helping rather than to talk about it afterwards."

'I'm sorry'

Despite their efforts, the doctor said there was nothing more they could do.

Mr Ellwood said: "I told a doctor present 'you're going to have to order me to stop', and the medic said, 'Sir, you've done your best, but you do need to stop'.

"We both covered the body as best we could, closed the eyes and I said, 'I'm sorry'.

"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."

Asked by the lawyer representing PC Palmer's widow, about security in Westminster, Mr Ellwood said there had always been a "sense of vulnerability" around the Houses of Parliament and that, at times, there had been less firearms protection at the site than he would have liked.

But he did not want it to become "a tower of protection", as it would "change the face of what Parliament is about".

The MP added: "[With] the level of security we have in place [now], I'm not sure we could do more."