Scotiabank has signed a deal to sell its landmark red skyscraper in downtown Toronto to a pair of real estate investment trusts for $1.27 billion.

The bank said Tuesday that Dundee REIT and H&R REIT have agreed to buy the building where it will become the chief tenant.

"Scotiabank is the only large bank that currently owns its headquarters in downtown Toronto, and given market conditions, this was an opportune time to maximize the value from those holdings," Scotiabank chief operating officer Sabi Marwah said in a statement.

The Scotia Plaza complex includes the main tower at 40 King Street West and the historic bank building at 44 King Street West as well as other smaller properties on the same block.

Scotiabank said it has signed a lease agreement that will secure its occupancy as the anchor tenant throughout the Scotia Plaza complex for an average of 13.5 years.

Under the deal, H&R will own a one-third interest in the office complex and Dundee will own the remaining two-thirds interest. The transaction is expected to close on or about June 20.

"With the addition of Scotia Plaza, the quality of our portfolio is the best it has ever been, the average cost of our debt is the lowest it has ever been and the cash generated per unit is the highest it has ever been," said Dundee REIT chief executive Michael Cooper in a release.

"Scotia Plaza is one of the most exceptional assets in Canada, by location, scale, physical condition and the strength of its tenants."

The sale of the office building will give Scotiabank a big infusion of cash ahead of new banking rules.

Under the incoming Basel III rules, a bank's required Tier 1 capital ratio must be at least seven per cent. The ratio of how much of the bank's assets include shareholder equity and other core capital is a key a measure of a bank's health and ability to endure downturns.

"It's all about being liquid and having good capital cushions," said Brad Smith, senior financial services analyst at Stonecap Securities in an interview.

"Having it (the headquarters) sit there as a non-eligible asset just wasn't as attractive as liquidating."

Scotiabank was the last of the big Canadian banks to own its headquarters. The 68-storey tower near the corner of King and Bay streets has been the home of Scotiabank's Canadian operations since it opened in 1988.

The building, at 275 metres, is one of the highest in Toronto, ranking behind First Canadian Place, which has 72 stories and stands 298 metres tall.

The Trump International Hotel and Tower, which is under construction, is expected to stand at almost 277 metres.

All of them are considerably shorter than the CN Tower, which soars 553 metres.

Shares of Scotiabank closed 51 cents higher at $51.62 on the Toronto Stock Exchange Tuesday, before the announcement was made.

Canada's biggest banks begin reporting their second-quarter earnings on Wednesday. Scotiabank is scheduled to report its results on May 29.