A Conservative MP has apologised for hacking into Harriet Harman’s website.

Kemi Badenoch said she carried out the “foolish prank” before she was elected to Parliament, more than a decade ago.

Ms Harman said she had received a written apology from the Tory MP and accepted it.

The prank is said to have constituted a breach of the Computer Misuse Act (CMA), potentially a criminal offence.

It prompted a call for the MP to be investigated, although others said the way it had been dealt with between the politicians showed such incidents did not have to result in criminal action.

Ms Badenoch, who was appointed the Conservative Party’s vice-chairwoman for candidates in January, made the confession in a lighthearted interview for the online Core Politics channel.

Asked what the “naughtiest” thing she had ever done was, the MP for Saffron Walden, in Essex, replied: “About 10 years ago I hacked into… a Labour MP’s website and I changed all the stuff in there to say nice things about Tories.”

She told the Mail on Sunday it was “a foolish prank over a decade ago, for which I apologise”.

It is understood it involved guessing a password on the website.

Tory sources stressed Ms Badenoch was not a candidate or professionally connected to the party at the time.

Ms Badenoch was elected to Parliament for the first time in last year’s general election.

Ms Harman tweeted: “@KemiBadenoch has written to me apologising. I have accepted her apology.”

Mustafa Al-Bassam, a computer science PhD researcher at University College London said he had reported the incident to cyber crime authorities at Action Fraud.

“I hope they do take this matter seriously, and apply the law equally to Tory MPs as they do to hacktivists who have gone to jail for less,” he said.

Naomi Colvin, director of activist charity the Courage Foundation, said Ms Harman’s acceptance of Ms Badenoch’s apology “renders the likelihood of a prosecution unlikely”.

She said: “This is an entirely appropriate way to deal with a trivial incident and highlights just how ridiculously heavy handed most prosecutions of online activists are.

“People have had their houses raided and equipment seized on lesser pretexts, when a settlement like today’s would be more consistent with the interests of justice and common sense.

“I look forward to working with Kemi Badenoch and Harriet Harman on amending the CMA and associated CPS (Crown Prosecution Service) guidance to defend online activists, security researchers and journalistic sources from inappropriate harassment.”