A Conservative MP has defended giving a character reference to an activist who went on to be jailed for sending a message claiming he would pay "crackheads" to harm Labour's Yvette Cooper.

Former Tory council candidate Joshua Spencer was sentenced to nine weeks' imprisonment and handed a 10-year restraining order at Leeds Magistrates' Court on Friday.

The 25-year-old constituent of the senior Labour MP wrote in April that he was working to get Ms Cooper "hurt" over her opposition to a no-deal Brexit, the Guardian reported.

Conservative MP Andrea Jenkyns released a statement insisting she stands by her decision to give the reference read in court.

"I have known Joshua for a number of years. I stand by my decision to have given him a personal reference," the MP for Morley and Outwood said.

"Josh has bipolar and had mental health issues since his father's suicide in 2015 and I was, and remain, concerned about his emotional and mental well-being and wanted to make absolutely sure it was taken into consideration as part of the judicial process.

"I will be seeking assurances that he will get the support he clearly needs as part of his rehabilitation."

The Guardian reported that he sent a message in April to a man he met on a dating website saying Ms Cooper should "pay" after MPs voted to delay Brexit past March 29.

"We should have left no deal on the 29th before the whore Yvette got her hands on to it and voted to revoke democracy. She will pay. I'm already organising... to hurt her," he wrote.

"Amazing what crackheads will do for £100. I'm going to get her beat up."

In another message, he said: "If you make peaceful revolution difficult you make a violent one inevitable."

In a statement to the court, the Pontefract, Normanton and Castleford MP said she has suffered numerous threats in the past but "this case was different and more serious".

"In this case the individual lives in my constituency, has contacted me directly on a regular basis, is an active member of the local Conservative Party and prominent in mainstream local politics in my constituency," she said.

She said her office had provided Spencer with "considerable casework assistance" throughout 2017 and that he went on to bombard her with messages and organise "a hostile event" outside her constituency office.

Ms Cooper has written to the Conservatives asking why Spencer was permitted to attend her election count in December as a Tory representative despite having been summonsed.

"As a result of his political role he will have known my movements for campaign events such as hustings as well as the count. My office had to inform the police about any event he might be present at, including the general election count, as we had no idea whether or what kind of threat he might pose," she said.

"It is only three-and-a-half years since my friend and colleague Jo Cox was killed while in her constituency. Threats of violence cannot be dismissed as banter between friends. Intimidation and violence has no place in our politics."

Spencer was a Conservative candidate for the Wakefield Council elections in May, which was reportedly a month after his arrest.

The activist, of Knottingley, West Yorkshire, admitted a charge of sending an offensive, indecent, obscene or menacing message by a public communication network.

The restraining order demands he does not contact Ms Cooper, including on social media, or go near her constituency office for 10 years, court staff said.