The US broadcaster behind channels such as Eurosport and TLC had threatened to remove its channels from Sky on 31 January after a dispute over fees.
Discovery said the new agreement would keep its programmes on Sky for "years to come".
Sky's UK chief Stephen van Rooyen said the deal was concluded on the "right terms".
No financial details of the agreement have been released by either company.
Many channels pay thousands of pounds to appear on Sky's platform. However, Sky also pays some channel providers to include their content in subscription packages.
Discovery had claimed Sky did not pay a "fair price" for its channels - but Sky said Discovery's threat to remove the channels was about "commercial self-interest".
Announcing the agreement, Mr Van Rooyen said: "The deal has been concluded on the right terms after Discovery accepted the proposal we gave them over a week ago."
A spokesman for Discovery said the deal was "meaningfully better than our former agreement and their proposal".
He said: "Our new arrangement enables us to control our destiny in more ways, with even more opportunities to invest and launch channels and consumer services."
Tim Westcott, senior principal analyst in TV programming at IHS Markit said Sky was probably looking for ways to save money when renegotiating channel carriage deals, as it copes with large rises in sports rights costs.
"Sky is trying to control its operating costs. One way of doing that is to cut back on what it pays channel providers," said Mr Westcott.
Discovery's portfolio in the UK includes Discovery Channel, Eurosport, TLC, Animal Planet and DMAX.  Its channels are also available on other services such as Virgin Media.
Sky also announced a new deal with PBS America that will bring the US broadcaster's factual programming to Sky, covering history, science, current affairs, arts and culture.
Satellite broadcaster Sky has secured a last-minute deal to keep 12 Discovery channels on its television service.