The operation will boost Repsol's output by 76 percent to 680,000 barrels of oil equivalent while its reserves will increase by 55 percent to 2,353 billion barrels of oil equivalent, the company said.
"The combined company will be among the 15 largest privately-owned oil and gas companies in the world, present in key areas and with the most potential worldwide," Repsol said in a statement.
If the transaction is completed, Repsol — which became a medium-sized player when Argentina nationalized its subsidiary YPF in 2012 — will have more than 27,000 employees in 50 countries.
Repsol's presence will be strengthened in North America, a market where Talisman is well placed, and South America, especially Colombia, as well as Algeria and the North Sea.
Buying Talisman also gives it access to the Asian market, from where it is currently absent, via Indonesia, Malaysia and Vietnam.
The deal, which is subject to regulatory approval, is expected to close in the second quarter of 2015, Talisman said in a statement.
Repsol said it would sell non-strategic assets picked up in the transaction once it is completed.
"This is an operation that frankly transforms Repsol," the company's chief executive officer, Josu Jon Imaz, told a news conference.
"It's a good agreement at the right moment," he added. Repsol said the deal should be financed mainly with the $6.3 billion which Argentina paid it earlier this year in compensation for seizing control of YPF. Repsol lost huge oil reserves with the nationalization.
After the nationalization Repsol said it would build up its presence in nations that are members of the Organisation for Economic Co-operation and Development, a club of mostly rich countries, rather than exposing itself to greater political risks typical of emerging economies.
The purchase of Talisman will mean that Repsol will have almost half of its capital in exploration in North America, compared with 22 percent in Latin America.
The deal will also boost Repsol's more profitable oil extraction activities in comparison to refining and distribution.
By combining the businesses, Repsol said it expected to achieve more than $200 million a year in savings.
"This is an extraordinary operation for Repsol, for the hydrocarbon sector and for the Spanish economy," Spain's Industry Minister Jose Manuel Soria told reporters.
Under the terms of the deal, Repsol will pay $8.3 billion for all of the outstanding shares of Talisman and will assume $4.7 billion in debt.
That amounts to $8.0 (6.42 euros) per Talisman share, a 24 percent premium over the average share price of the last three months.
The price is "higher … than discussed in the market", said RBC Capital Markets analyst Biraj Borkhataria.
Talisman said in July that it had been approached by Repsol but the Spanish firm reportedly pulled out because the price for the company was too high.
Since then Talisman's shares have dropped.
The Standard and Poor's ratings agency in October cut Talisman's credit rating to triple-B-minus, one notch above junk, citing concerns about the company's limited ability to generate enough cash flow to offset high operating costs.
Talisman loaded up on debt as it aggressively pursued overseas expansion. It is now struggling to reduce its debt load amid a slump in oil and gas prices.
"This deal creates significant and immediate value for Talisman stakeholders," Talisman head Chuck Williamson said in a statement.