Jonathan Coe’s portrait of a Britain torn apart by the Brexit referendum, Middle England, has won the Costa novel award, described by judges as the perfect fiction for these times.

Moving from 2010 to 2018, Middle England features characters including a married couple divided over the EU vote, and an enthusiastic new member of a group called Students for Corbyn. On Monday night, Coe’s state-of-the-nation novel beat books by Sophie Hardach, Rowan Hisayo Buchanan and Joseph O’Connor to the £5,000 prize.

Costa judge and novelist John Boyne said that “if people are serious about healing the country and bringing it back together, this [book] can help do that because it presents in a careful, thoughtful way both sides of a debate”.

Boyne praised Coe’s ability to show both sides of the conversation. “More than anything I’ve read in newspapers or non-fiction, Middle England helped me understand what has led people to vote to leave the EU,” he said. “One of the jobs of a novelist is to present humanity, not heroes or villains. I know Coe is an adamant remainer, but he was very, very good at analysing both sides – and in such a way that it was also a great story.”

Middle England continues the story of Benjamin Trotter, who first appeared in Coe’s books The Rotters’ Club and The Closed Circle, and is now a failed novelist who finds himself unexpectedly longlisted for the Booker prize. It will now compete with the winners of the Costa prizes for first novel, children’s book, poetry and biography for the overall title of Costa book of the year.

“It’s so funny – and there’s not enough humour in novels,” said Boyne. “Humour is a great skill and he’s shown it throughout his career. I think he’s one of Britain’s best novelists and I don’t think he’s got the recognition that he deserves. He’s never been longlisted for the Booker, or shortlisted for the Costa before now, which is bizarre.”

Coe, whose biography notes that his work has received many prizes and awards, mainly from continental Europe, said it was “a wonderful compliment” to win a prize which has gone to names from Ali Smith to Andrea Levy in the past.

“I couldn’t be more thrilled that Benjamin Trotter and his friends, who I’ve been writing about for almost 20 years, have now been elevated to this distinguished company,” he said.

In the other category prizes announced on Monday evening, the first novel award went to Sara Collins for her gothic tale The Confessions of Frannie Langton, written after Collins worked in the Cayman Islands as a dispute resolution lawyer for 17 years, and raised five children. It tells of a Jamaican maid on trial for the murder of her employers in 1826 London, and was inspired by the story of the Jamaican boy Francis Barber, who was sent into service in the household of Samuel Johnson.

Winning her Costa award was surreal, said Collins. “I think it’s a story of hope for people who have hit 40 to realise there can be another life after that,” she said. “I was a lawyer for a long time and people think I then had this revelation and decided to become a novelist. But the whole time I was a lawyer I realised I had made a wrong turn. It was one I made the most of, but I was still miserable at heart because I think I was born wanting to be a novelist.”

After her youngest child went to secondary school, she enrolled on a creative writing master’s at Cambridge. “I realised if I didn’t try to do it then, I wouldn’t have time,” she said. “But it was the most difficult thing I’ve ever done … I had to keep myself going through some real physical and mental torture writing this book and it still seems impossible to me that we did get there in the end, Frannie and I.”

The Costa judges, who picked Collins’s debut over titles including Candice Carty-Williams’s bestselling first novel, Queenie, said: “This book is the full package – we all loved it.”

The Costa biography award went to former war reporter Jack Fairweather for The Volunteer, the “extraordinary, chilling and masterful” story of the underground operative Witold Pilecki who infiltrated Auschwitz. The poet and lecturer Mary Jean Chan took the poetry category for her first collection, Flèche, which judges called a “staggeringly beautiful mix of the personal and political”. And Jasbinder Bilan’s Asha and the Spirit Bird, about a girl living in the foothills of the Himalayas who embarks on a quest to find her missing father, won the Costa children’s book award.

The Costas are intended to reward the most enjoyable book in each category, with the winner of the overall £30,000 book of the year prize to be announced on 28 January. Last year’s book of the year was Bart van Es’s biography of the Jewish girl his grandparents had hidden during the second world war, The Cut Out Girl.