Leveson inquiry: Mail on Sunday editor Peter Wright has said his paper continued to use investigator Steve Whittamore after he was charged in February 2004. Photograph: Carl Court/AFP/Getty Images

The Mail on Sunday continued to use a private investigator after he was charged with illegally obtaining private information including criminal records, the paper's editor has admitted at the Leveson inquiry.

Lord Justice Leveson heard that the Mail on Sunday spent £20,000 on the private detective's services over a number of years and did not stop using him entirely until 13 months after he was arrested in relation to the illegal trading of private information.

Steve Whittamore was arrested in August 2003 in relation to trading illegally obtained information with the press including mobile phone numbers, car registration plates and criminal records, following the information commissioner's Operation Motorman investigation.

When it became apparent that Whittamore was going to be prosecuted the paper issued "instructions that enormous care should be taken when commissioning Whittamore".

Those instructions were issued in February 2004, the same month that Whittamore was charged, the paper's editor, Peter Wright, told the Leveson inquiry on Wednesday.

Asked by inquiry counsel Robert Jay QC whether this posed a risk to the paper, Wright replied: "Our action dated from the point at which we became aware that Whittamore was going to be prosecuted. It was around the turn of the year 2003/04 and in February of that year we took steps to stop using Whittamore, or at least only use him when we were extremely sure that what he was doing was legitimate and there was a good reason to do it."

He told Leveson that the paper did not stop using Whittamore altogether until September 2004, although there were two unaccounted for payments to him after that. The Mail on Sunday banned all external search agencies in 2007.

However, Wright told the inquiry he did not know until August 2011, when the paper was given access to the information commissioner's Operation Motorman files, that Whittamore had been obtaining information he was supplying to the Mail on Sunday illegally and that "nobody had suggested" that he was doing anything other than legitimate research for the paper.

He was used up to 2004 because he had databases of publicly available information such as electoral registers and was so efficient at tracing people's telephone numbers and addresses, at a time when reporters had laptops but no internet access. "I don't think it occurred to anybody that he might be doing illegal things," said Wright.

In early 2004 suspicions were raised because of the information commissioner's Operation Motorman investigation and a resulting police inquiry. Wright said he became aware that there may have been an issue relating to a story published in the paper about union leader Bob Crow getting a lift to work during a strike on the back of a scooter.

The story, headlined "Well, how else would Bob Crow, scourge of commuters, get to work?", was published on 2 February 2003 and was partly based on confidential DVLA information supplied by Whittamore that identified the owner of the scooter.

Wright told the inquiry that in early 2004, after concerns were raised about the Crow story, he checked invoices of payments to Whittamore, which were "very vague" about what exactly the private investigator had been doing for the paper.

"I was uncomfortable that it appeared he might be using methods of which we would not approve, without the knowledge of those who were commissioning him," Wright said.

He added that from the extent of the payments to Whittamore it also seemed clear that he was being asked to do legitimate information searches "that should have been done by reporters themselves".

Wright told the inquiry that Whittamore's notes had logged "that the name of the owner of the scooter had been supplied to us by Whittamore" but he was not aware "who on the newspaper if anyone asked him for this". "It's a reasonable assumption that they did, but we don't know."

When police raided Whittamore's offices they discovered he had about 17,000 requests for information from journalists including for mobile phone numbers, car registration plates and criminal records.

The logs formed the basis of the information commissioner's 2006 report, What Price Privacy, which ranked the Mail on Sunday as Whittamore's fourth most frequent customer with "266 positively identified transactions" with the private detective.

Whittamore pleaded guilty in 2005 to illegally accessing data and trading information with the media.

Wright said he was unaware of the paper's use of Whittamore, whose invoices were categorised alongside regular journalistic expenses such as taxis and accommodation, until Operation Motorman was brought to his attention.

He denied this was any attempt to "cover up the use of these people".

• This article was amended on 13 January 2012. The original incorrectly stated that Peter Wright had admitted that the Mail on Sunday continued to use Steve Whittamore after he was charged with obtaining medical records and that this was 18 months after he was arrested. This has been corrected.

• To contact the MediaGuardian news desk email editor@mediatheguardian.com or phone 020 3353 3857. For all other inquiries please call the main Guardian switchboard on 020 3353 2000. If you are writing a comment for publication, please mark clearly "for publication".

• To get the latest media news to your desktop or mobile, follow MediaGuardian on Twitter and Facebook.