Actor Robert Blake tried to freeze his girlfriend out of their baby daughter's life — and the two married only to avoid a court custody battle, friends of the murdered mom said yesterday.

Bonny Lee Bakley, found shot to death inside the couple's car on May 4, and the former TV cop decided that a convenience marriage guaranteeing both of them access to the now 11-month-old was a better solution than letting a judge decide, her pals said. 

Blake's legal team has suggested that Bakley was out to trap the former Baretta star into marriage. It's been alleged she took fertility drugs to assure her pregnancy, as a passport to life as the wife of a Hollywood celebrity. 

The baby was born last June, and Blake took physical custody of her for more than three weeks between August and September, the friends said. 

At other times during those two months, "He kept moving the baby around to different baby sitters and wouldn't let Bonny Lee see," one of Bakley's friends said. "He didn't want Bonny Lee to be in her life at all." 

The friends said Blake used the woman's past — including her alleged efforts to scam lonely men through newspaper and Internet ads — against her, the friends said. 

They claimed he threatened to turn her in for violating probation by traveling without permission. 

"Bonny Lee was scared she'd never see her baby again because Blake had threatened to turn her in," another friend said. 

Then the two married, with Bakley signing a prenup and living with the baby in a guest house on Blake's property. 

The little girl is now staying with Blake's friends and family as cops try to solve the slaying. 

The couple had been out to dinner on the night of her death. After leaving a Studio City restaurant, Blake said, he went back to the eatery to retrieve a gun he accidentally left behind, and then returned to the car to find his slain wife.