Getty/Instagram Composite
Exclusive

Bam Margera On Brink of Legal Win ... Judge Says Nikki Was Never His Wife

Bam Margera and Nikki Boyd were never husband and wife in the eyes of the law, despite going through a wedding ceremony -- that's the word from the judge in their ongoing custody battle.

According to new legal docs, obtained by TMZ, the judge issued a tentative ruling Tuesday saying Bam and Nikki were never legally married.

Remember, Nikki claims her 2013 wedding to Bam was legal, but he maintains it wasn't legit because the ceremony went down in Iceland, and they never got a license in the U.S. to make it official.

Bam tells TMZ ... "Nicole knew that were weren't married since day one, it was common knowledge and it wasn't new information. Of course I won, because we were never married, but paying a fistful of dollars for a four-day trial about it acting like she didn't know is a time-consuming pain up my a**, but I'm used to it."

Nikki's attorney, David Glass, tells us his client insists she was under the impression their Iceland marriage was valid -- saying he respects the court's ruling, but doesn't agree with the outcome, and he's weighing options to appeal assuming the tentative ruling becomes final.

Bam and Nikki have been squabbling over their marital status since splitting and fighting for custody of their son Phoenix.

Their marital status is important for their division of property, and spousal support issues ... but the court said, even if they weren't legally married, there will still be legal issues to deal with in the case ... like custody and child support.

The former "Jackass" star has already gotten hitched since splitting with Nikki ... tying the knot with Dannii Marie over in New Mexico.

Click here for info about our online advertising practices.