The 48-year-old coach succeeds Ben Howland, who was fired last weekend after 10 years and a 233-107 record that included three consecutive Final Four appearances and four Pac-12 titles. The Bruins were 25-10 this season, which ended with a 20-point loss to Minnesota in the second round of the NCAA tournament.
Alford led New Mexico to a 29-6 record this season that included the Mountain West regular-season and tournament titles. But the Lobos were upset by Harvard in the second round of the NCAAs shortly after Alford's new deal with the school had been announced.
Alford will be introduced at UCLA on Tuesday.
"I have been so fortunate and blessed in my life, and an opportunity to lead one of the greatest programs in college basketball history is once-in-a-lifetime," he said in a statement.
Alford had a 155-52 record in six years at New Mexico, with the Lobos making three trips to the NCAA tournament. He was selected Mountain West coach of the year three times.
His other head coaching stints were at Iowa (2000-07), Missouri State (1996-99) and Manchester College (1992-95) in his native Indiana.
Alford is a legend in the Hoosier state, where he starred at Indiana University from 1984-87 under coach Bob Knight. The Hoosiers won the national championship in his senior year. He also played on the gold medal-winning 1984 U.S. Olympic basketball team in Los Angeles as a college sophomore. Knight coached that team.
Alford was drafted by the Dallas Mavericks in 1987 and played four years in the NBA before starting his head coaching career at tiny Manchester.