Under the code, Google and Microsoft's 'Bing' will take steps to demote links to copyright-infringing content within their search results. Music and film industry bodies, the BPI and Motion Picture Association, are the other signatories of the code.
The code has also been endorsed by the Alliance for Intellectual Property, whose members include the Premier League and the Publishers Association.
"The code will accelerate the demotion of illegal sites following notices from rights holders, and establishes ongoing technical consultation, increased co-operation and information sharing to develop and improve on the process," a statement issued by the BPI said. "It will also enable new practices to be adopted where needed."
Geoff Taylor, BPI chief executive, said: "The code will not be a silver bullet fix, but it will mean that illegal sites are demoted more quickly from search results and that fans searching for music are more likely to find a fair site."
Talks on the new code were facilitated by the UK's Intellectual Property Office (IPO), which will oversee its implementation. The IPO said the code "sets targets for reducing the visibility of infringing content in search results by 1 June 2017".
Jo Johnson, UK minister for universities, science, research and innovation, said: "I am very pleased that the search engines and representatives of the creative industries have agreed this code. I look forward to this valuable collaboration benefiting both the UK’s digital and creative sectors."
In a statement, a spokesperson for Google said the company "has been an active partner for many years in the fight against piracy online". They said Google "remain committed to tackling this issue and look forward to further partnership with rights holders."
A Microsoft spokesperson said: "We are pleased to have reached agreement on this code of conduct for search-related copyright issues, and we thank the UK government for leading this industry-wide initiative forward."