Daniel Conroy's victim was left suffering from a stammer in the wake of her late night ordeal.
Conroy left a night bus in Edinburgh after his victim and began following the 28-year-old woman who had just finished work at a pub in the city.
He suddenly grabbed the woman from behind in a bear hug and told her not to move as she would be stabbed.
Advocate depute Gillian Wade told the High Court in Edinburgh: "The victim swore, struggled and begged the accused to leave her alone."
"The accused offered her 100 to have sex with him. When she refused he offered her 200 and then 300, telling her to imagine what she could buy for that amount," said the prosecutor.
She said: "In his drunken frustration at not being allowed intercourse he subjected her to a serious, violent physical assault."
Conroy, 22, tried to drag the Polish woman to a gate, but found it locked and then pulled her towards a tenement door. "The victim started screaming and he put one hand over her mouth," said the advocate depute.
She managed to break free but was grabbed by her ponytail and dragged back towards the gate. Conroy then held the woman in a bear hug again and told her that if they crossed the street in silence nothing would happen to her.
But when they reached the other side of Moredun Park Road, in Edinburgh, he tried to pull her towards steps.
Ms Wade said: "She struggled and tried to brace her feet against a wall. She was terrified. She started screaming for help and the accused seized her ponytail again."
The woman lost her footing and fell to the ground and curled up as she was scared she would be kicked, but her attacker ran off.
During the assault Conroy had asked his victim where she came from.
After he was refused to have sex with him for money he called her a "Polish f****r" and told her she did not belong here.
After the attack the woman made an emergency call but when she was put through to police was too distressed to speak.
Conroy, of Craigour Crescent, Edinburgh, was traced with the help of CCTV footage from the bus.
He was originally charged with assaulting the woman with intent to rape her on May 13 this year.
But the Crown accepted his guilty plea to a reduced charge of assaulting the woman to her injury and accepted the attack of itself was "not sexual". He also admitted making remarks of a racist nature towards her.
The advocate depute said that as a result of the attack the woman developed a stammer, was unable to go anywhere on her own and moved flats.
Defence solicitor advocate Vincent Belmonte said first offender Conroy was very sorry for his behaviour and wished to apologise to the victim through him.
He said: "There was no actual sexual contact in the attack itself."
Mr Belmonte said: "There was a substantial amount of alcohol taken by the accused."
Lord Kinclaven told Conroy that he had admitted a serious offence involving an attack on "a total stranger to you".
"It was a terrifying, physical assault on a stranger with the racial aggravation," said the judge.
"Fortunately, the victim's only physical injuries were tenderness to her side," he said, but noted that she now suffered from a stammer and her lifestyle has been restricted.
He said he was satisfied that there was no alternative to a custodial sentence in the case and added: "No other method of dealing with you is appropriate."
The judge told Conroy he would have faced a five-year jail term but for his guilty plea.
Lord Kinclaven said he was satisfied that there was "a significant sexual aspect" to his behaviour in committing the assault and ordered he should be placed on the sex offenders' register.