Merck will get an upfront payment of $850 million from the U.S. drugmaker for sharing rights to develop its experimental immunotherapy drug with Pfizer.
It is also eligible for up to $2 billion in payments based on the medicine's future success.
Merck's MSB0010718C is part of a class of drugs known as anti-PD-L1 therapies, which work by blocking a tumour's ability to evade the immune system's defences.
The exclusive nature of the deal means Pfizer and Merck cannot collaborate with any other drugmaker in the PD-LI or related PD-1 area, unless they jointly agree to do so.
Such immune-boosting medicines represent the hottest area of cancer research and are also a major focus for AstraZeneca, which has a rival anti-PD-L1 product in development called MEDI4736.
Winning access to AstraZeneca's cancer pipeline has been viewed as a major goal for Pfizer, which was unsuccessful with a $118 billion bid for the British group in May. It has a chance to renew its approach under British takeover rules from Nov. 26.
Shares in Merck jumped 2.4 percent on the news, while AstraZeneca slid 2.2 percent by 1010 GMT. The British company's stock had already fallen on Friday after several people familiar with the matter said Pfizer seemed unlikely to renew its approach.
Pfizer said immuno-oncology was "a top priority" for the firm but a spokeswoman said British rules did not allow it to make any comment on its intentions towards AstraZeneca.
As a result of the cost of the deal, Pfizer said it now expected its 2014 reported diluted earnings per share to be between $1.40 and $1.49, compared with $1.50-1.59 indicated previously.
The drugmaker is paying a high price for a medicine that has yet to prove itself in full-scale clinical tests, reflecting intense competition among firms wanting to do a deal, according to Belen Garijo, who will head Merck's healthcare business from next year.
Merck said in September it in talks about a partnership deal for the drug, which is being investigated as a treatment for lung and ovarian cancer, as well as the rare skin cancer Merkel cell carcinoma.
Pfizer and Merck will develop the German company's treatment as a single therapy as well as in combinations with Pfizer's and Merck's portfolio of approved and experimental drug candidates.
Up to 20 high clinical development programmes are expected to begin in 2015, including as many as six Phase II or III trials that could be used to seek regulatory approval.
Merck's drug is some way behind rivals from Bristol-Myers Squibb, Roche, AstraZeneca and U.S. namesake Merck & Co, so advancing it quickly in clinical tests with a deep-pocketed partner such as Pfizer makes good sense, according to analysts at Berenberg Bank.
Pfizer and Merck will jointly fund all development and marketing costs, and will share all revenues. They also agreed to co-promote Pfizer's Xalkori cancer drug in the United States and other markets.