Sept 7 (Reuters) - State Street Corp said on Tuesday it had agreed to buy investment bank Brown Brothers Harriman & Co's (BBH) investor services business for $3.5 billion in cash, strengthening its hand in the battle to be the world's biggest custodian bank.

The deal, which the companies said would include BBH's custody, accounting, fund administration, global markets and technology services operations, comes less than a year after reports that State Street was looking to offload its other main business, asset manager State Street Global Advisors.

A custodian bank holds customers' securities for safekeeping to prevent them from being stolen or lost.

Adding BBH's $5.4 trillion in assets under custody to State Street's $31.9 trillion portfolio will help the combined company challenge Bank of New York Mellon for supremacy as the market providing custodian and other administrative services to the banking sector.

Founded in 1818 and headquartered in New York City, BBH counts institutions, privately held companies, families and wealthy individuals as its clients.

BBH will continue to operate its separate private banking and investment management businesses after the sale of its investor services unit, the banks said.

The deal, which is expected to close by the end of the year, will also give Boston-based State Street access to BBH's expertise in cross-border, alternatives, exchange-traded funds, and other high-growth asset classes.

State Street Chief Executive Officer Ron O'Hanley said it would enhance the bank's position and scale on a range of services and markets and grow relationships with many of the leading global asset managers.

Media reported late last year that the other half of the bank's business, State Street Global Advisors, one of the biggest asset managers in the world, was up for sale. Executives have been mum on that deal since, which would align with Tuesday's move to focus on the custodian business. https://reut.rs/3n9qMrT

Goldman Sachs & Co. LLC served as financial adviser to State Street, while Lazard advised BBH. (Reporting by Noor Zainab Hussain in Bengaluru; Editing by Vinay Dwivedi and Patrick Graham)