A pact may be needed to keep Labour out of government at next general election, the Tory mayor says.