The 21-year-old had been at Fiorentina for three-and-a-year years since joining them from Partizan where he began his professional career.
He flourished under the leadership of Vincenzo Montella last season, scoring 13 goals to help the team finish fourth in Serie A.
Ljajic has been involved in controversy during his career.
Serbia coach Sinisa Mihajlovic dropped him last year for refusing to sing the national anthem before the team's friendly with Spain,
Ljajic, a Slav Muslim from southern Serbia's ethnically mixed region of Sandzak bordering Bosnia and Montenegro, said he had refused to sing the anthem because of personal beliefs and would not change his stance.
Ljajic, a player with quick feet, cheeky skills and a powerful striker of the ball, also clashed with former Fiorentina coach Delio Rossi during a Serie A match.
Rossi was sacked for punching Ljajic after the forward sarcastically applauded him having been substituted midway through the first half of Fiorentina's 2-2 draw with relegated Novara in May last year.
Roma had a disappointing last season when they missed out on a European place and lost the Coppa Italia final to arch-rivals Lazio.
They have since parted with defender Marquinhos, goalkeeper Marten Stekelenburg, midfielder Erik Lamela and forward Pablo Osvaldo.
Incoming players include Netherlands midfielder Kevin Strootman, Morocco defender Mehdi Benatia, Brazil fullback Maicon, Ivory Coast forward Gervinho and goalkeeper Morgan De Sanctis.
- Sports & Recreation
- Vincenzo Montella