Macfarlane was elected to the House of Representatives at the 1998 federal election, representing the Division of Groom for the Liberal Party. As a minister in the Coalition Government under John Howard he held the portfolio of Minister for Small Business from January 2001, before being promoted to the Cabinet role of Industry, Tourism and Resources in November 2001. After the defeat of the Coalition in the 2007 federal election he served in the shadow portfolios of Trade as well as Infrastructure and Water, and was the Shadow Minister for Energy and Resources.