Harry was an unintentionally made Horcrux of Lord Voldemort. When Voldemort killed Lily Potter and later tried to kill Harry, his spell backfired on him due to Lily's protection for Harry. However, since Voldemort couldn't die because of his previous Horcruxes, the remaining part of his soul latched onto Harry, thereby creating a connection between the minds of him and Voldemort. This is why Harry was capable of seeing visions like the killing of Frank Bryce and the attack on Arthur Weasley by Nagini.