Ecolab Inc. is buying the Travelers Cos.’ 17-story tower in downtown St. Paul, a deal that keeps two major companies in the capital city.

Terms of the deal weren’t immediately available, but the sale is expected to close in the third quarter.

Travelers confirmed in January that it was negotiating the sale of the tower, which is 882,000 square feet with 484,500 square feet of office space and is a landmark in downtown St. Paul with its pyramid-shaped top.

The building, one of two on Travelers’ St. Paul campus, is known within the company as its north tower. Travelers will move its St. Paul staff into its south building, which is five stories tall and covers most of a city block.

The two buildings are connected by a skyway over W. 6th St. and occupy a prominent spot in the city center near the St. Paul Hotel, which Travelers owns.

Travelers, a New York-based insurance giant, was formed in the 2004 merger of the St. Paul Cos. and Travelers Property Casualty Corp. of Hartford, Conn. It still has sizable operation in Hartford as well as St. Paul.

Ecolab, a provider of cleaning products and services for companies, has about 2,500 employees split among three downtown St. Paul buildings and a campus in Eagan. The company has grown substantially in recent years through acquisitions, with $14 billion in sales in 2014.

The purchase will allow it to occupy a higher-tier office building and centralize its employees without leaving the city’s core, though it’s unclear what will happen to the three downtown buildings, totaling 460,000 square feet, that it leases or owns. One of its leases expires June 30, 2018, the other at the end of 2019, “and we are exploring our options on the six-story building we own,” said Roman Blahoski, spokesman for Ecolab.

The office shuffling will begin as soon as the deal is finalized and will take several years. When all the pieces are in place, the two companies will share the common areas in the north tower, including a day care center, fitness room and cafeteria.

St. Paul Mayor Chris Coleman announced the news in his State of the City address Thursday night.

“I want to thank Ecolab Chairman and Chief Executive Doug Baker for his commitment to the city of St. Paul,” Coleman said. “And I also want to thank Travelers for their commitment to the future of St. Paul as they will continue to have over 2,000 employees at their downtown campus.”

While the deal frees Travelers of lesser-used real estate, the company said in January it was committed to the city.

“St. Paul is the second-largest campus for Travelers, and we remain very connected to the local community,” said Matt Bordonaro, spokesman for Travelers, in January. “In anticipation of a successful conclusion of a sale, plans are in place to move people to the south building. And that would take place over a two-year time period.”

Russ Nelson and Tina Hoye, principals at the real estate firm NTH, represented Ecolab in the deal.