Marriott International Inc. agreed to acquire Starwood Hotels & Resorts Worldwide Inc. for $12.2 billion, a surprise outcome to a heated process that involved some of the world’s largest hotel groups.

The combination would create the No. 1 hotel company globally—with more than a million rooms—and bring together 30 brands across all lodging segments, from Starwood’s higher-end W Hotels, St. Regis and Westin brands to Marriott’s limited-service offerings like Courtyard by Marriott and its extended-stay chain Residence Inn.

...