Allen, 41, has not played in the NBA since the 2013-14 season, when he was with the Heat. He had been linked with multiple teams over the last two years and recently considered making a comeback with the Warriors and Cavaliers, league sources told ESPN.
As part of a "letter to my younger self" posted Tuesday on The Players Tribune, Allen wrote, "I write this to you today as a 41-year-old man who is retiring from the game."
Allen was a 10-time All-Star over a career spent with four teams -- the Heat, Celtics, SuperSonics and Bucks. He won two NBA championships -- one with Boston in 2008, the other with Miami in 2013 -- and is the league's all-time leader with 2,973 career 3-pointers made, 413 more than anyone else to date.
In his post, Allen praised former teammates LeBron James, Dwyane Wade, Kevin Garnett and Paul Pierce.
"The men who you are going to win championships with are all going to be very different people," he wrote. "What makes them champions is the boring old habits that nobody sees. They compete to see who can be the first to get to the gym and the last to leave."
Allen averaged 18.9 points per game in 1,300 regular-season contests and shot 89.4 percent from the free-throw line, the seventh-best percentage in league history.
"When you start getting some national attention in high school, you'll hear things like, 'Ray's jump shot is God-given,'" Allen wrote. "Listen: God doesn't care whether you make your next jump shot.
"God will give you a lot of things in life, but he's not going to give you your jump shot. Only hard work will do that."
Allen is the last member of the Celtics' famed Big Three to announce retirement plans this year.
Garnett, 40, retired on Sept. 23 after a 21-year NBA career. Pierce, 39, announced three days later that he would retire after playing this season with the L.A. Clippers.
Celtics general manager Danny Ainge issued a statement, saying: "As one of the greatest shooting guards in the history of basketball, Ray Allen defined the word professionalism. Ray was born with special talent, but it was his leadership, tireless preparation, and infectious work ethic that made him a great teammate and champion. We would not have won the 2008 title without him."
Teammates and coaches raved about Allen's famed work ethic and commitment to fitness -- which now takes a different form, after he and his wife, Shannon, recently opened an organic fast-casual restaurant in Miami. Allen was almost always on the floor for a workout three hours before games, shooting on some occasions before the arena lights were even turned on.
Wade said Tuesday that Allen inspired him.
"I learned so much from Ray towards the end of his career, how he took care of his body, longevity and what it takes mentally and physically," he said. "[He had] a Hall of Fame career, man."
He added: "He pushed us to do things differently. He pushed us to take our bodies a different way. He talked to us about eating a different way and all kinds of stuff, man. So Ray was obviously an unbelievable basketball player but I think a lot of us are going to remember the person and what he meant to our team."
Allen had the record for 3-pointers in a season for seven years, his mark of 269 standing until Stephen Curry made 272 in 2012-13 -- a record Curry has topped twice.
Allen's record of 2,973 3-pointers made in regular-season games doesn't even count the one that was his most unforgettable.
His 3-pointer from the right corner with 5.2 seconds left in Game 6 of the 2013 NBA Finals for Miami sent the Heat to overtime against the Spurs in a win-or-else game, and helped them go on to win the title in seven games. Chris Bosh got an offensive rebound and passed to Allen, who was backtracking toward the corner.
Allen, without even needing to look down to ensure that he was behind the line, elevated over Tony Parker and connected to tie the game -- even as arena workers kneeled around the court, holding the rope that they presumed they would soon be called upon to cordon things off for the Spurs' championship celebration.
On his way back to the bench to prepare for overtime, Allen gestured to those workers, shouting to put the rope away.
"It was just perfect," Wade said. "No one else could hit that shot on our team but Ray, the way that it happened. It's crazy because he practiced it all the time. Ray has a drill where he sits on his butt, and he gets up and he backpedals back to the the 3-[point line] and he makes it. That's one of the drills he does in the morning. So you look at that, you look at how he had to backpedal back to the 3-point line and get it off with defenders all on him. He practiced that over and over. I know coaches say all the time but remember that whole practice makes perfect [motto]? That was a moment where practice really makes perfect and we got a championship because of it."
Allen, who played for UConn from 1993 to 1996, also starred in the 1998 Spike Lee film "He Got Game," portraying Jesus Shuttlesworth, a top-ranked basketball prospect whose father (played by Denzel Washington) is in prison for killing his wife.
"Basketball will take you far away from that school yard," Allen wrote. "You will become far more than just a basketball player. You'll get to act in movies. You'll travel the world. You will become a husband, and the father of five amazing children."
The Associated Press contributed to this report.
Russillo: Ray Allen had great NBA run
Ryen Russillo stops by SportsCenter to talk about Ray Allen's retirement and what he meant to the game of basketball.