Bayliss, 44, who currently coaches New South Wales, replaces another Australian Tom Moody, who quit last month to work with Western Australia.
"Bayliss has been appointed for a two-year period starting on August 1," Sri Lanka Cricket (SLC) spokesman Samantha Algama told AFP.
Bayliss was picked over fellow Australian Terry Oliver, the Queensland coach, after being interviewed by SLC's selection panel here on Thursday.
The panel included SLC officials and former captains, including Aravinda de Silva, Ranjan Madugalle, Michael Tissera, Sidath Wettimumy and Bandula Warnapura.
Bayliss played 58 first-class matches for New South Wales as a middle-order batsman from 1985 to 1993 before making his mark as the state coach when he took over from Steve Rixon during the 2004-05 season.
Bayliss had told the Sydney Morning Herald last week he would take up the Sri Lanka job if it was offered to him after rejecting overtures from Bangladesh and Australia's Centre of Excellence.
"It's a job with an international team, and one of the better international teams, so you'd be nuts not to hear them out," Bayliss was quoted as saying by the paper.
"And if something was offered, you'd be silly to knock it back. I spoke to Tom (Moody) about a week ago just to find out what I can expect in the interview."
Sri Lanka made it to the final of the recent World Cup in the Caribbean where they lost to Australia.
New South Wales chief executive Dave Gilbert had told the same paper that Bayliss will not be stopped from taking up the Sri Lanka job.
"We won't be standing in the way of Trevor," Gilbert said. "If he wants to prove himself on the international stage, we will stand aside.
"We don't want to lose him, but we realise he is very ambitious, and in the long term he wants to coach Australia. Coaching another international side would be a big step towards that goal.
"Just look at the way it catapulted Tom Moody to the upper echelons of world cricket."
Trevor Penney, who was Moody's assistant and will join him at Western Australia after his term ends on July 31, will coach Sri Lanka during the upcoming home series against Bangladesh.
Bayliss' appointment comes as the SLC is involved in a row with the sports ministry over the continuation of Asantha de Mel as chairman of selectors.
Sports Minister Gamini Lokuge has turned down an SLC demand to have de Mel removed after he slammed the team's participation in three one-day matches against Pakistan in Abu Dhabi soon after the World Cup.
Bayliss' appointment fills the first vacancy for coaches in all four Asian Test nations.
India are still looking for a coach after South African Graham Ford rejected an offer to succeed former Australian captain Greg Chappell, who quit after the World Cup.
Pakistan's Bob Woolmer died during the World Cup and Dav Whatmore did not renew his contract with Bangladesh in April.