North Wiltshire MP James Gray is celebrating today after winning a ballot which means he keeps his job.

Tory members have voted to keep him on as MP at the next General Election despite his affair with married countryside campaigner Phillipa Mayo while his wife Sarah fought breast cancer.

The result of a ballot of almost 1,000 North Wiltshire Tory members, announced moments ago at a press conference in Chippenham, showed the party's grass roots support for him has held firm.

Mr Gray said: "I am delighted to have won the ballot and I pledge to repair the damage caused during the run-up to the voting."

Party officials are refusing to say how many votes were cast or how many voted for Mr Gray.

The ballot came after the party's executive voted to axe him over his affair with countryside capaigner Phillipa Mayo while his wife Sarah fought breast cancer.

Mr Gray, 52, who has been an MP since 1997, had asked for the vote to be put to members. It sparked a bitter campaign against him from three disaffected senior Tories, who write t omembers saying he was unfit for the job because he had not been truthful about his affair.

This week Mrs Gray broke her silence on the affair and condemned her estranged husband for belittling her fight against breast cancer in a letter to the Press Complaints Commission.

Mr Gray had said in the letter, complaining about a story in the Mail on Sunday, that her treatment had been mainly for pre-cancerous cells and objected to its use of the term cancer-stricken'.

" Needless to say, I have been deeply hurt by my husband's behaviour over the last few months and the constant coverage it generated but his letter undermining my cancer has moved me to respond,'' she said.

James Gray factfile

James Gray was born in Scotland, the son of a doctor mother and a Minister of religion father (John Gray, minister at Dunblane Cathedral, and later Moderator of the General Assembly of the Church of Scotland in 1977.) He was educated at the Hillhead Primary School, Glasgow and the Glasgow High School, before studying history at the University of Glasgow where he was awarded a master's degree in 1975. He furthered his studies at Christ Church, Oxford where he completed his history thesis in 1977.

He worked as a graduate management trainee with P&O for a year until 1978 when he was appointed as a ship broker with Anderson Hughes where he remained until his appointment as the managing director of GNI Freight Futures in 1984, in which capacity he served until 1992. He was a member of the Baltic Exchange from 1978, becoming a director of the futures exchange 1989-91. From 1977 he served in the Honourable Artillery Company within the Territorial Army based in Islington for seven years. In 1978 he became a Freeman of the City of London, and was awarded the Lloyd's of London Book Prize in 1987.

Prior to his election to Parliament Gray acted as a special advisor to the Secretary of State for the Environment Michael Howard and his successor John Gummer 1991-3, and in 1995 was a director of the lobbying firm Westminster Strategy, where he remained until his election to parliament. He also served as governor of two schools in Balham in the London Borough of Wandsworth.

He unsuccessfully contested the Scottish Highlands seat of Ross, Cromarty and Skye at the 1992 General Election but was defeated by the sitting Liberal Democrat MP Charles Kennedy by 7,630 votes. After the election he was elected as the vice chairman of the Tooting Conservative Association for two years in 1994.

At the next election, 1997 General Election, Gray was elected to the House of Commons as MP for the Wiltshire North constituency following the retirement of the Conservative MP Richard Needham. Gray won the seat with a majority of 3,475 and has remained the MP there since. He made his maiden speech on June 11, 1997, in which he spoke of his constituency's largest town of Chippenham, and of his sadness at the massacre in his childhood home town of Dunblane.

He was appointed as a frontbench spokesman on education and employment by William Hague in 1999, becoming an Opposition Whip in 2000. Following the 2001 General Election he was appointed as a spokesman on defence by the new party leader Iain Duncan Smith. He was moved in 2003 by Michael Howard as the spokesman on transport and the environment. After the 2005 General Election he entered the Shadow Cabinet as the Shadow Secretary of State for Scotland, however his role was short lived when he was forced to resign on May 19, 2005 after calling for Members of the Scottish Parliament to be abolished. 2 He is the chairman of the all party group on multiple sclerosis.

His local constituency campaigns have included unsuccessfully fighting against closure of Malmesbury Hospital, opposition to the closure of RAF Lyneham airbase and opposition to possible closure of Chippenham hospital.

He married Sarah Ann Beale in 1980 and they have two sons and a daughter.