The writer of Line of Duty, Jed Mercurio has thanked fans after the much-anticipated episode was watched by more than 12 million viewers.

During Sunday night’s episode of the BBC One series, DSU Ian Buckells, played by Nigel Boyle, was unmasked as the mysterious H, the corrupt police officer at the top of a criminal conspiracy.

Mercurio also addressed the series’ divisive ending, writing on Twitter: “We’re honoured and flattered by the viewing figures for #LineofDuty6. We knew attempting to explore the real nature of corruption in our society wouldn’t appeal to everyone, but we do sincerely thank you all for watching. It’s been our privilege to share your Sunday nights.”

Fans of the series were split over the finale reveal, with Irish author Marian Keyes tweeting: “Like, NO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I’ve NEVER felt so LET DOWN!!!!!! #LineOfDuty.”

Some critics were impressed, with The Times’ Ben Dowell giving it four stars out of five, writing: “Perhaps Mercurio has more surprises in store. It’s the sort of thing he does. Roll on series seven I say.”

Martin Compston, who plays Steve Arnott, revealed that he, Adrian Dunbar (Ted Hastings), Vicky McClure (Kate Fleming) and series creator Mercurio had agreed to get “AC12million” tattoos if the show hit the milestone. He joked that it was an “inconceivable and ridiculous scenario”.

The much-anticipated episode was watched by an average of 12.8 million people, with a 56.2% share in overnight viewing figures, making it the most watched episode of a drama in 20 years, the BBC said. The episode also had a peak viewing figure of 13.1 million.

In a message posted on Twitter, Compston thanked those who had reached out to him since the episode aired.

He wrote: “Hey folks now the madness is slightly dying down just want to thank everybody who reached out about last night and the series as a whole, we’ve truly been blown away by the reaction and love for the show we’re proud of it. “Fully understand it wasn’t the ‘urgent exit’ type ending some anticipated but we appreciate you sticking with us.

“Felt many emotions from excitement and anxiety at the hype to relief that it’s over. Now I just feel immense pride our show that started on Wednesday’s on BBC2 has just smashed every overnight drama record since they began.

“Finally myself, Vicky, Adrian and Jed made an agreement in the inconceivable and ridiculous scenario we ever got twelve million viewers we would get ‘AC12million’ tattoos. We’ll see who’s good to their word……”

McClure replied: “We are so grateful to you all. So much so looks like I’ll have the ink to prove it!”

Charlotte Moore, the BBC’s chief content officer, said: “Addictive event television, Line Of Duty has kept the nation guessing for the last seven weeks, so it’s no surprise that last night’s jaw-dropping finale set a ratings record.

“Jed Mercurio is a master of his craft, and I would like to congratulate him and the entire cast and crew for delivering such an incredible drama series. I’m looking forward to having a conversation with the team about where we go next and what the future of the series might be.”

Born Gerald Gary Mercurio in Nelson, the 55-year-old is a former hospital doctor and Royal Air Force officer.

The penultimate episode earned an average of 11 million viewers and 51.7% of the audience share, according to the BBC.