The civil guard in 2019 posted a 45-second video showing a man viciously punching and kicking a woman unconscious and then trying to remove her clothes.
While the incident took place in China, he wrote it showed the rape of a woman in the coastal town of Canet de Mar at the hands of a minor who arrived in Spain without his parents.
He also claimed in the post, which was seen nearly 22,000 times, that mainstream media was covering up the rape.
Public prosecutors said the man had published several other racist and xenophobic messages on social media.
They had been seeking a two-year jail term but just before his trial, the policeman admitted the crime and accepted a shorter sentence in exchange, the court in Barcelona said.
The policeman was also served a fine of €1,620 ($1,619) in one of the first ever sentences in Spain for spreading disinformation.
He is not expected to serve time in jail since in Spain prison terms of under two years are usually suspended if the person does not have a criminal record.
Spain’s Civil Guard has launched a disciplinary procedure against the agent, according to internal sources in the police force.