Note: This video contains some violence
The male lawmakers attacked Amy Ndiaye after she criticised an opposition religious figure.
The judge also ordered Mamadou Niang and Massata Samb to pay Ms Ndiaye five million CFA francs ($8,100; £6,750) in compensation.
The incident was widely condemned and sparked a debate about women’s rights.
In a video widely shared online, Mr Samb is seen walking towards Ms Ndiaye and slapping her during a routine budget debate on 1 December. She then retaliates by throwing a chair, but at the same time gets kicked in her belly by another male colleague. A melee then breaks out as other MPs try to calm the situation.
Ms Ndiaye, a member of the ruling Benno Bokk Yakaar coalition, fainted in parliament after the attack and there were fears that she would lose the baby.
Despite leaving hospital she “remains in an extremely difficult situation,” her lawyer Baboucar Cissé told news agency AFP.
Despite the video evidence, lawyers for Mr Niang and Mr Samb argued in court that their clients had not physically attacked Ms Ndiaye.
They also argued unsuccessfully that the two lawmakers were immune to prosecution.
“They are going to remain in prison pending an appeal,” one of their lawyers, Abdy Nar Ndiaye, told AFP.
There has been tension in Senegal’s parliament since the government lost its majority in legislative elections in July last year.