John Stafford, 33, had turned up, drunk, at the woman’s home in Leven, Fife, in the early hours of the morning.
Advocate depute Jennifer Bain, prosecuting, told the High Court in Edinburgh that the 27-year-old mum had prepared a bottle for her seven-week-old son and was sitting with him in her living room.
“The accused stood in front of her, placed his hands on her neck and squeezed it, forcing her backwards onto the couch,” said Ms Bain.
The woman began crying when Stafford took the baby and put the tot in a rocker in the living room before continuing the attack.
“He then removed his lower clothing, grabbed her by her housecoat and threw her to the floor,” said the prosecutor.
“He grabber her pyjama trousers and although she held on to the waistband and shouted ‘No’ he managed to remove them.
“He punched her to the left side of the head, gabbed the left side of her pants and ripped them away from her body before pinning her down.”
The court heard that Stafford tried but failed to have sex with the woman and began to cry as she lay on the floor in shock.
He threw her housecoat over her, said he was sorry and fled from the house.
Police arrived at the mum’s home to find her “visibly upset and physically shaking” said Ms Bain.
Doctors found bruising to her left temple, a black eye, red marks on her neck and injuries to her mouth,chin and ear. She also suffered bruising to her arm and hip.
Stafford drove to his grandfather’s house in Dundee. When arrested he told police he had taken an over-dose of tablets and had tried to kill himself.
In court he pleaded guilty to attempting to rape the woman and to driving to Dundee when he had only an expired provisional licence and no insurance.
Stafford - who appeared from custody - was further remanded pending sentence in Glasgow next month when background reports - including a report on his mental health - have been prepared.