<P> John is also surprised to discover that Sherlock is in a relationship with Mary's bridesmaid, Janine . Sherlock tells John that he is dating her because she is Magnussen's personal assistant, and he uses their relationship to assist him with breaking into Magnussen's office in London . Inside, Sherlock and John find an incapacitated Janine, and Sherlock happens upon Mary holding Magnussen at gunpoint . Mary shoots Sherlock, who harnesses all his mental powers to stay conscious . He is taken to hospital . In his mind palace, Sherlock fades away, at the same time in the real world Sherlock dies on the operating table in pre-op preparation . In the mind palace, Moriarty convinces Sherlock that he's letting John down by dying, which convinces the mind palace Sherlock to wake up and escape . At this time, in the real world, Sherlock's heart begins to beat again . The surgeons attempt to help revive him, by giving him oxygen . Sherlock wakes up in surgery and mouths "Mary". Mary comes into the hospital and is met by John, who says that Sherlock had survived surgery . Mary visits the dazed and severely injured Sherlock and warns him not to denounce her . John nonetheless begins to suspect something after he finds that Sherlock replaced John's chair in the Baker Street flat and left a bottle of Mary's perfume on the table next to it . </P> <P> Sherlock breaks out from the hospital and arranges a meeting with Mary . Using a ruse, Sherlock exposes Mary's secret life as an assassin to John, and all three return to Baker Street to talk it out . She tells them about her past, and that Magnussen has information on her that would put her in jail for the rest of her life . Sherlock deduces that she intentionally shot him in a non-lethal spot and called an ambulance . Sherlock tells John that he observes John's addiction to danger and that John was most probably attracted to Mary because of her hidden past . Mary gives John a memory stick containing information on her, marked with her true initials A.G.R.A., telling him the contents will destroy his love for her . After not viewing the memory stick for a few months, John decides to destroy it without reading it and realises he loves Mary unconditionally . The couple spend Christmas with the Holmes brothers at their parents' home, where Sherlock takes the opportunity to drug everyone but John so that they can steal Mycroft's laptop . Sherlock takes a hesitant John to meet Magnussen at his estate, Appledore, which he believes contains Magnussen's blackmail archive . During their confrontation, Magnussen explains his purpose in putting pressure on Mary was to arrive at Mycroft via John and Sherlock . He also reveals that he was behind the kidnapping of John, as seen in "The Empty Hearse". </P> <P> Sherlock offers to trade Magnussen's information on Mary for the state secrets contained in Mycroft's laptop . However, Magnussen is aware that Sherlock is setting him up in a trap . Magnussen then explains Sherlock's plan to John: security services looking for the laptop using a GPS tracker it contains will raid Appledore and, upon finding the laptop, will have a legal reason to search the blackmail vaults . Magnussen, with visible joy, reveals that the plan will not work because Appledore's vaults don't physically exist, but are stored in his mind palace . By giving Magnussen the laptop, Sherlock and John are now guilty of attempting to sell government secrets and can be imprisoned for high treason, whereas Magnussen remains legally untouchable . When Mycroft and the police arrive, Sherlock coldly shoots Magnussen in the head, having realised that this is the only way to free his friends and everyone else from his power . </P> <P> Mycroft convinces the government to spare Sherlock a trial and, as an alternative punishment, press him into a highly dangerous mission in Eastern Europe . He is, however, recalled within minutes when TV screens all over Great Britain are hacked to broadcast a loop of a static image of Jim Moriarty asking "Did you miss me?" A post-credits scene shows a very much alive Moriarty asking if the audience missed him as well . </P>

Who did sherlock shoot at the end of season 3