Hanvey was subsequently elected as MP for Kirkcaldy and Cowdenbeath at the 2019 election, gaining the seat from the Labour Party's shadow Scottish secretary Lesley Laird by a narrow majority of 1,243 votes or 2.6%.