Image copyright Reuters Image caption James Clapper is the highest ranking US official to publicly implicate China

China is the "leading suspect" in the massive hack of a US government agency holding the personnel records of millions of Americans, US intelligence chief James Clapper has said.

He is the highest-ranking US official to publicly implicate Beijing since news of the data breach emerged.

China always dismissed suggestions that it was behind the hacking.

The statement comes after three days of high-level talks in which China and the US agreed to a "code of conduct".

"China remains the leading suspects," said Mr Clapper at a conference in Washington DC, but "the US government continues to investigate" he added, according to his office.

Background to a "massive" hack in five points

On 5 June the US Office of Personnel Management (OPM) said more than four million employees, retirees, contractors and job applicants may have had their personal data compromised

Some reports have put the number at 14 million or higher - this remains unconfirmed

The OPM first became aware of the breach in April

Members of the Senate Intelligence Committee said the hackers were believed to be in China

It's not the first attempt: In March 2014 hackers breached OPM networks - an intrusion blamed on China - but the attempt was blocked

US hit by 'massive data breach'

China military unit 'behind prolific hacking'

At the Washington talks where cyber security was a top priority, US Secretary of State John Kerry said there was a need to work with China to develop a "code of conduct" on state behaviour in cyberspace - Chinese representatives had agreed with these conclusions.

"It's something that we agreed needs to be addressed and hopefully it can be addressed soon," State Department spokesman John Kirby said on Thursday.

China has said any suggestion that it was behind the hacking is "irresponsible and unscientific".