Avago, which serves the wireless and industrial markets, is offering Broadcom shareholders $17 billion in cash and Avago shares valued at $20 billion.
The deal is the biggest so far by Avago Chief Executive Hock Tan, who has developed a small chipmaker into a $36 billion company through acquisitions since taking the helm nine years ago.
Tan, a serial deal-maker, has trimmed Avago's portfolio by divesting units while bulking up in faster-growing areas.
The combined company, to be based in Singapore and known as Broadcom, will be the third-largest U.S. semiconductor maker by revenue, behind Intel and Qualcomm. The merger is the industry's second megadeal this year and is unlikely to be the last, analysts said.
The $37 billion price represents a premium of about 28 percent over Broadcom's market value of $28.85 billion as of Tuesday's close, before the Wall Street Journal reported that the companies were in talks.
Demand for cheaper chips and new products to power Internet-connected gadgets is driving consolidation in the industry.
The Avago-Broadcom deal follows NXP Semiconductors' $11.8 billion offer to buy Freescale Semiconductor Ltd in March. Avago had also bid for Freescale, people familiar with the matter said at the time.
Intel has also been in talks to buy chipmaker Altera Corp in a deal that could top $10 billion.
Until Thursday, Avago's biggest deal was for chipmaker LSI Corp, which it bought for $6.6 billion last year.
Tan's strategy has been to look at potential targets that do not necessarily have the best strategic fit but have cost-cutting potential to build value.
Avago and Broadcom first spoke about a potential merger in October 2014 but could not agree on a price, said people familiar with the matter who are unauthorized to speak publicly about it.
Talks heated up in April when Avago approached Broadcom again with higher offers, and negotiations continued until the two agreed on a deal.
Private equity firm Silver Lake Partners, which is an Avago investor and holds a board seat, worked closely with the company to help evaluate Broadcom and structure the deal, said two sources who are unauthorized to speak publicly about the deal.
The merger will help the companies improve their bargaining position with manufacturers.
Irvine, California-based Broadcom has been struggling to grow as competition in the mobile chip business intensifies. The company's revenue increased by just 1.5 percent last year.
Broadcom's shares closed down 1.5 percent at $56.25 on Thursday, while Avago's fell 0.62 percent to $142.38.
The companies said they expected to close the deal by the end of the first quarter of 2016 and save $750 million within 18 months. The deal has a breakup fee of $1 billion, one of the unidentified sources said.
The new Broadcom would have annual revenue of $15 billion and an enterprise value of $77 billion, the companies said in a statement.
Broadcom shareholders will own about 32 percent of the combined company. They would also have the option to choose between various combinations of cash and stock.
Avago, which is incorporated in Singapore and also has headquarters in San Jose, California, said it intended to fund the cash portion of the deal by using funds from the combined company and new debt of $9 billion.
Avago was advised by Deutsche Bank, Bank of America, Barclays, Citigroup and Credit Suisse.
Broadcom was advised by JPMorgan Chase, while Evercore served as financial adviser to the Special Committee of the board.
Skadden, Arps, Slate, Meagher & Flom LLP is the legal adviser to Broadcom. Broadcom co-founder Henry Nicholas was advised by Centerview and Morrison & Forester.
© Thomson Reuters 2015