The point where the atmosphere of the Earth 'ends', and anything further can be called 'space', is the Kármán Line. On the Earth, this line is just over $100 kilometres$ from the surface. However as we know, the ISS orbits at $400 kilometres$, and still faces air resistance and drag that requires correction. Hence the Kármán line alone does not define where air resistance itself stops.
In this interesting answer, Mark Adler calculates the Mars-analog of the Kármán line to be $88 Km$. Therefore if you are higher than $88 km$ on Mars, you are technically in space.
However, he goes on to say that the actual safe altitude, below which a spacecraft is considered to be 're-entering', is $125 Km.$
At Earth for Apollo it [altitude below which atmosphere is significant] was defined as 400,000 feet, or about 122 km. At Mars is has been defined at 125 km. That is when the $n$ minutes of terror begins.
This is very interesting, because I'm sure $n$ minutes of terror is not an ideal scientific flyby of Mars. My own personal guess is that the webpage you linked to does not reflect the exact altitude of the flyby, but rather an approximation for public understanding. Another possibility is that they want to intentionally aerobrake, but that's inconsistent with a free-return mission.
For reference, Rosetta flew by Mars in February 2007, making it's closest approach at $250 Km$. Leaving room for error, based on Mark Adler's answer, I would say that a flyby of $150 Km$ should be safe.