Electronic payment technology company Global Payments (GPN - Get Report) on Tuesday said it agreed to buy credit card transaction firm Total System Services (TSS - Get Report) in an all-stock deal valued at $21.5 billion.

Under terms of the deal, Global Payments will pay Total System shareholders 0.8101 in Global Payments shares for each common share they own. In dollar terms, that adds up to $119.86 a share, a 20% premium to Total System Services' closing price of $99.62 as of May 23.

Shares of Total System Services surged on Friday on rumors of a pending deal, climbing nearly 10%. The stock was up 4.83% to close at $118.84 on Tuesday on the New York Stock Exchange. U.S. financial markets were closed on Monday for the Memorial Day holiday.

Global Payments CEO Jeff Sloan will lead the combined company following the completion of the transaction, which is expected to close in the fourth quarter. Total System CEO Troy Woods will become chairman of the combined company, 52% of which will be owned by Global Payments shareholders, while Total System investors will own 48%.

. @GlobalPayInc and TSYS Combine to Form Leading Pure Play Payments Technology Company https://t.co/J6gJIt9lVn pic.twitter.com/ecixtgSS16

— TSYS (@TSYS_TSS) May 28, 2019

After closing, the combined entity is expected to generate about $8.6 billion annually in adjusted net revenue plus network fees, with $3.5 billion in earnings before interest, taxes, depreciation and amortization and $2.5 billion in free cash flow, the companies said.

The merger, which had been months in the making, creates a payment processing juggernaut that provides payment technology and software to more than 3.5 million small- to mid-size merchants, and more than 1,300 financial institutions both in the U.S. and globally, the companies said in a statement.

It also marks the third big merger in the technology payments space this year. In January, Fiserv (FISV - Get Report) announced a $22 billion takeover of First Data (FDC - Get Report) , and in March, Fidelity National Information Services (FIS - Get Report) agreed to buy Worldpay (WP - Get Report) for $34 billion.

Shares of Global Payments were down 2.98% to close at $148.87 on Tuesday. They ended the day Friday up 3.7%, or $5.46, at $153.44.