PASIPHAE (the Polar-Areas Stellar Imaging in Polarization High-Accuracy Experiment) is an optopolarimetric survey aiming to measure the linear polarization from millions of stars, and use these to create a three-dimensional tomographic map of the magnetic field threading dust clouds within the Milky Way. This map will provide invaluable information for future CMB B-mode experiments searching for inflationary gravitational waves, providing unique information regarding line-of-sight integration effects. Optical polarization observations of a large number of stars at known distances, tracing the same dust that emits polarized microwaves, can map the magnetic field between them. The Gaia mission is measuring distances to a billion stars, providing an opportunity to produce a tomographic map of Galactic magnetic field directions, using optical polarization of starlight. Such a map will not only boost CMB polarization foreground removal, but it will also have a profound impact in a wide range of astrophysical research, including interstellar medium physics, high-energy astrophysics, and evolution of the Galaxy. Taking advantage of the novel technology implemented in our high-accuracy Wide-Area Linear Optical Polarimeters (WALOPs) currently under construction at IUCAA, India, we will engage in a large-scale optopolarimetric program that can meet this challenge: a survey of both northern and southern Galactic polar regions targeted by CMB experiments, covering over 10,000 square degrees, which will measure linear optical polarization of over 360 stars per square degree (over 3.5 million stars, a 1000-fold increase over the state of the art). The survey will be conducted concurrently from the South African Astronomical Observatory in Sutherland, South Africa in the southern hemisphere, and the Skinakas Observatory in Crete, Greece, in the north.