CANBERRA, Australia—Hackers based in Iran and implicated in attacks on the U.S. and Western allies were behind a computer breach of Australia’s Parliament and political parties, a U.S. cyber research company alleged.

This month’s attacks were part of a global espionage campaign that cybersecurity companies say began last year and that has mostly targeted the Five Eyes intelligence alliance comprising the U.S., Canada, the U.K., Australia and New Zealand. They think the attacks were retaliation for President Trump’s decision...