Fan returned to the Legislative Council in the 2018 New Territories by-election following the disqualification of localist Baggio Leung of Youngspiration over the Legislative Council oath-taking controversy in March. He was elected with more than 180,000 votes, defeating the pro-China common candidate Tang Ka-piu of the Hong Kong Federation of Trade Unions (FTU) and the Democratic Alliance for the Betterment and Progress of Hong Kong (DAB). He was then removed from the Legislative Council after the Court of Final Appeal declined to hear an appeal from a lower court which held that he was not duly elected as the Returning Officer for the election disqualified another candidate who was not given an opportunity to respond.