A firearms officer on duty at the Palace of Westminster during the attack by Khalid Masood unknowingly disobeyed written instructions on how to do his job, he told an inquest.

PC Lee Ashby told the Old Bailey he was unaware of instructions that required roving firearms officers to be in close proximity to the gates but not outside them, and not to work in pairs. When asked, he agreed that the security system had not been functioning for years and had “completely failed” PC Keith Palmer, who was stabbed by Masood as he guarded the palace gates.

Dominic Adamson, representing the widow of PC Palmer, who was stabbed by Masood as he guarded the palace gates, asked Ashby about written instructions, drawn up in January and December 2015.

Ashby told Tuesday’s inquest hearing he was operating on the basis of different instructions on a map on the wall of the base room at the Palace of Westminster.

“We worked always as a pair,” said Ashby, adding that briefings always referred to patrolling the palace yard in its entirety rather than just close to the gates.

Ashby and his colleague PC Nicholas Sanders were near Carriage Gates for only 14 minutes of the 108 minutes leading up to the attack, the court heard on Monday, when CCTV footage showed that the last time armed officers were at the gates was at around 1.45pm, almost an hour before Palmer was attacked at 2.41pm.

Ashby also said he was not made aware of the contents of a tactical planning review that said the focus of firearms officers should be the Carriage Gates, or internal police emails expressing concern that firearms officers were spending too much time in Cromwell Green.

Addressing the officer, Adamson said: “The result is that the unintended effect is the gates more often than not … [were] simply left unprotected.”

Ashby replied: “Yes sir.”

A department of professional standards report described the conduct of all of the firearms officers with respect to patrols as “poor practice”, the inquest heard.

But Ashby said that in the 18 months since the attack no one had told him he had done anything wrong or how he had done so, and no one from the department of professional standards had been in contact. Nor had any concerns been raised with him before the attack, he said.

Ashby said that if he had been making the decisions, he would have had firearms officers fixed at the Carriage Gates.

When asked whether it was possible to adequately protect the gates while also being responsible for patrolling a wider area, he replied: “No sir.”

Under questioning, Ashby agreed that, had he been stationed at the gates, he might have had a chance of a clear shot at Masood as he ran through them. This opportunity was not available to him at the time of the attack because of his location.

Adamson asked Ashby: “The system of security completely failed to protect PC Palmer, did it not on that day?”

Ashby replied: “It appears so.”

Ashby and Sanders took one-and-a-half minutes to get to the scene after Masood had been shot by a close protection officer.

The firearms officers were moved to conduct roving patrols about 18 months to two years before Masood struck on 22 March 2017 so that their movements were more unpredictable to hostile reconnaissance and terrorist attacks, the inquest heard on Monday.

Masood, 52, killed Kurt Cochran, 54, Leslie Rhodes, 75, Aysha Frade, 44, and Andreea Cristea, 31, when he mowed down pedestrians on Westminster Bridge before stabbing Palmer to death.

The inquest continues.