ROME—A movement that channeled Italians’ rage at mainstream politicians struck a pact with a hard-right nationalist party to govern the country, a major prize for the political insurgencies that have been shaking Europe’s establishment.

The 5 Star Movement, an eclectic upstart group driven by scorn toward Italy’s ruling elites, on Sunday evening said it had agreed on the outlines of a governing program with the anti-immigration League party, clearing the way for a likely coalition government. The parties said they would slash...