Actor David Hasselhoff has received primary custody of his two teenage daughters.

Superior Court Judge Mark Juhas ruled Hasselhoff's ex-wife, Pamela Bach, could visit the girls on alternate weekends and Wednesday nights for dinner, Hasselhoff's attorney, Melvin S. Goldsman, said Friday.

The ruling marked a startling reversal for the actor, who was banned from seeing Taylor-Ann, 17, and Hayley, 14, after a video of the actor drunk surfaced in May. Hasselhoff regained his parental rights by agreeing to alcohol testing, reported People magazine.

The former "Baywatch" star, now a judge on "America's Got Talent," left the courtroom smiling, telling reporters, "Enough is enough, these children have been through enough."

Bach didn't comment, but was seen crying in the courthouse hallway, People said. Hasselhoff, 54, and Bach, 42, filed for divorce in January 2006 after 16 years of marriage. They have battled over money and custody of their daughters ever since.