The revised directive on protecting laboratory animals is designed to boost welfare without hindering research and will come into effect in two years.
Under the new arrangements, national authorities will have to assess the animal welfare implications of all scientific experiments involving animals with a view to promoting alternative testing methods where possible.
The EU has also agreed to protocols minimising the pain inflicted on animals and tightening the rules on the use of primates in experiments.
The deal was hammered out after lengthy negotiations between MEPs and member states and means scientists can continue to use animals in basic research and to study human, animal or plant diseases, as well as drug testing and species preservation.
Animals can also be used in higher education and forensic investigations under strict conditions.
Use of some primates essential for brain research
The legislation broadly bans the use of great apes such as chimpanzees, bonobos, gorillas and orang-utans for scientific testing.
The Commission's draft law would also have restricted the use of other primates such as ouistitis and macaques but MEPs felt this could hamper scientific research into neuro-degenerative illnesses such as Alzheimer's.
The Parliament and the Council agreed to allow the use of such primates if there is scientific evidence that the goal of the test cannot be achieved without using these species.
The original proposal from the EU executive had also sought to limit repeated suffering by suggesting that animals can only be reused if a test is painless or involves "mild" pain.
However, MEPs feared this would prove too strict and could result in a higher number of animals being used for tests, which would undermine the spirit of the directive. The reuse of animals will now be allowed even after tests involving "moderate" pain, provided a vet is consulted first.
National authorities will be expected to conduct inspections to ensure the new rules are followed by research institutions.
The agreement has been welcomed by the research-based pharmaceutical industry and most political groups. However, the Greens and animal rights organisations say the revised directive does not go far enough.