A spy ship is a dedicated ship intended to gather intelligence, usually by means of sophisticated electronic eavesdropping gear. In a wider sense, any ship intended to clandestinely gather information could be considered a spy ship.
Spy ships are usually controlled by a nation's government, due to the high costs and advanced equipment required. They tend to be parts of the nation's navy, though they may also be operated by secret services and masquerade as civilian ships such as fishing trawlers, which could be reasonably expected to remain in a certain area for a long time.
Spy ships in the modern sense have been used at least since the early Cold War, and are in use by all major powers. Their uses, in addition to listening in on communications and spy on enemy fleet movements, were to monitor nuclear tests and missile launches (especially of potential ICBMs).
One of the most important functions for both Cold War spy ship fleets, especially in the 1960s, was the gathering of submarine 'signatures' - the patterns of noise that could often identify the specific type of submarine and were thus valuable in anti-submarine warfare. During that era, the USA fielded about 80 vessels, usually classified as 'environmental research' craft, while the Soviets had around 60 ships, often converted trawlers or hydrographic research ships.
In the late 1980s, the Soviet fisheries fleet was known for having equipped many of their thousands of ships with sophisticated SIGINT and ELINT equipment, thus functioning as auxiliary spy ships tracking western naval vessels and electronic communications (though their main function remained commercial fishing).
A spy ship usually stays in international waters (or at least outside of territorial waters), so as to not violate territorial borders. From there, it will use its electronic gear to monitor sea and air traffic, radio and radar frequencies and also try to intercept and decrypt coded radio or phone communications. This is mostly done via passive means such as radio receivers or passive sonar. Sometimes however, active measures such as radar or sonar may also be used to detect the movement of aircraft, missiles, ships or other vehicles or troops. However, this risks revealing the ship's purpose.
As it is located much closer to the surveilled area than a fixed installation (given a close-by shoreline), the monitoring is usually much more efficient and in some respects better than even that of spy satellites.
Tracking vessels for space missions / control stations for satellites / spy satellites also have some of the capabilities of spy ships, and as they are controlled by their national governments, it can be considered reasonable that they are intermittently used for similar purposes, such as tracking enemy missile tests.