The ants are probably helping to "milk" the aphids that are feeding on the pear. Get rid of the aphids and the ants will disappear, too. When practical, try washing aphids off the tree host with a strong stream of water. Most aphids can be controlled with the use of insecticidal soaps. Insecticidal soaps are non-toxic and safe to use in backyards.
You can also apply a sticky substance to the base of the tree in a manner that will “catch” the ants as they attempt to crawl up the tree.
Beneficial insects play an important role in aphid control. Lady beetles (both adults and larvae), lacewings, some flower flies (larvae), and tiny parasitic wasps will use aphids as a source of nourishment for the development of their offspring.
Some species of aphids can be controlled with neem (azadirachtin) - a horticultural oil.
As a last resort get some Sevin insecticide and spray the entire tree-covering both leaf surfaces. Repeat the spraying in 10 days. Whenever using pesticides, be sure to read and follow the directions and heed the cautions found on the label. Be sure to follow all label instructions. That should take care of the problem. Sevin is a short residual insecticide. Remember certain insecticide applications will destroy these beneficial insects as well as targeted pest species. This practice could leave trees and shrubs unprotected if pest populations should increase in the future.
To prevent future outbreaks of aphids spray the pear trees with dormant oil in the spring. Below is a link that will provide additional information on aphids and aphid control. http://ento.psu.edu/extension/factsheets/aphids
Good luck with your efforts