In early 1977, Hayden challenged Whitlam for the party leadership and was defeated by just two votes. He replaced Whitlam as Leader of the Opposition at the end of the year when Whitlam resigned as a result of Labor's defeat at the 1977 election. He was replaced by Bob Hawke in 1983. 