Dler Mohammed had denied the attempted murder of Diana Pranskuniene in the stabbing attack outside Barclays Bank, in London Road, North End, last year.
The homeless 43-year-old had been in the city for less than a week when he planned to kill the 36-year-old on July 9.
CCTV played at Portsmouth Crown Court showed he planted the kitchen knife at the delivery gate at Sainsbury’s Local in the street between 8.30am and 9am on the day.
Sentencing, judge Sarah Munro QC said: ‘You planned the attack and concealed the knife nearby while you hung around all day for your target to appear.
‘You plunged the knife into her back, narrowly missing vital organs.
‘Your intention was to kill her and it’s a matter of pure good fortune that you did not do so.
‘Whilst the resultant physical harm caused is relatively minor, death was a distinct possibility.’
Shocking CCTV footage captured the moment Mohammed attacked Ms Pranskuniene, just moments after she aborted a 999 call as he had confronted her.
The court heard Mohammed had tried to call his brother Hiwar Namiq the day before and was ‘angry’ that Mr Namiq did not answer his phone.
Members of the public chased Mohammed to Derby Road after the stabbing at around 3.20pm.
Pierce Power, for Mohammed, told the court Mohammed had been held at Ravenswood for treatment.
A medic initially found the defendant may have been suffering from a psychotic episode at the time of the attack but after observing Mohammed for several months said this was not the case.
Mr Power said ‘trauma’ the defendant suffered growing up in Iraq was ‘intrinsically linked to what is otherwise a completely random incident of violence.’
Ms Pranskuniene was rushed to Queen Alexandra Hospital in Cosham following the attack with the knife lodged in her back.
Medics transferred her to Southampton General Hospital where the blade was removed.
Judge Munro imposed a 19-year prison sentence with a four-year extension on licence.
Mohammed will serve two thirds of the term before a parole board considers him for release.