Britney Spears nearly came face-to-face with her ex-husband when he attempted to crash her wedding and got inside her home ... so says one of her fired security guards.
Jason Alexander is in court Monday for a preliminary hearing, and witnesses are testifying about what went down the day Britney was getting married to Sam Asghari ... and some of the testimony is terrifying.
One of Britney's security guards -- who's since been fired over the incident -- told the judge Alexander beelined it straight for Britney's bedroom after sneaking onto the property and getting inside the main house. The guard testified, Alexander tried opening Britney's bedroom door while she was inside, but it was locked.
What's more, the guard said Alexander kept repeating that he needed to talk to Britney and was looking for her, even though he was not on the guest list.
TMZ broke the story ... Alexander, who cops say was armed with a knife, live streamed himself getting onto Britney's property and up to the second level of her home, demanding to see her on her wedding day. Police arrested him before he was able to make contact with Britney.
The security guard, who got fired by Britney shortly after the incident, also testified Alexander had been spotted on the outskirts of the property multiple times leading up to the wedding ... including the day before, despite being told to stay away.