According to official results cited by AFP, the European-supporting Liberal Democrat candidate Jane Dodd defeated Chris Davies of Johnson's ruling Conservative party by 13,826 to 12,401 votes.
The vote was triggered when Conservative lawmaker Chris Davies was ousted by a petition of constituents after being convicted of falsifying expenses, Reuters said.
According to the UK-based media, the by-election result is reportedly a blow to Prime Minister Boris Johnson in his first electoral test since taking office.
Johnson made it clear this week that he wanted the United Kingdom to leave the European Union on 31 October "come what may", although he said he preferred an orderly exit.
He has been calling on the commission to drop a clause that seeks to avoid a hard Irish border by tying the country to the EU customs union, despite Brussels saying it will not reopen talks on the Brexit deal.