The 38-year-old was part of Glamorgan's 1997 Championship winning squad before playing a key role in their one-day league triumphs in 2002 and 2004.
The experienced bowler played the first nine Twenty20 matches this season as Glamorgan reached the quarter-final.
Cosker took 957 wickets in total for Glamorgan and England A in his career.
"Dean has been a Glamorgan man through and through and has played an important role in the club's successes over the past two decades," said Glamorgan chief executive and Cosker's former team-mate Hugh Morris.
"Dean has enjoyed a terrific career with Glamorgan and has been a great ambassador for the Club both on and off the field for more than 20 years."
Cosker, who toured with England A in 1997/98 and 1998/99, also played in two Lord's finals in 2000 and 2013 and was 12th man when England beat Australia in the first 2015 Ashes Test in Cardiff.
"I feel very humbled and privileged to have had the opportunity to represent Glamorgan Cricket over the past 21 years,"
"I have been very lucky to rub shoulders with some of the game's finest players and characters," said Cosker.
"I have loved my time at Glamorgan and feel proud to say this was the only county I ever wanted to play for. Leaving the spin bowling department at Glamorgan in an exciting place has always been important to me and, with positive young spin bowlers at the club coming to the fore, I believe this is the case."
Glamorgan's longest-serving current player and spin bowler Dean Cosker has announced his retirement following 20 years at the Welsh county.