Alessandro Riario was born in Bologna on 3 December 1543, the son of patricians Palatine Count Giulio Riario, and Isabella Pepoli. He was related by marriage to Pope Gregory XIII. He was educated at the University of Padua and then at the University of Bologna, becoming a doctor of both laws on 11 May 1563.
As a young man, he moved to Rome where he became a protonotary apostolic and a Referendary of the Apostolic Signatura.Pope Pius IV made him a domestic prelate. On 1 May 1562 he became secretary apostolic. He served as auditor general of the Apostolic Signatura from 3 April 1565 to 1578.
On 8 November 1570 he was elected Titular Patriarch of Alexandria. He accompanied Cardinal Michele Bonelli in 1571 on his legation to Spain, the Kingdom of Portugal, and the Kingdom of France designed to promote a league against the Ottoman Empire. Riario was consecrated as a bishop in the Sistine Chapel on 24 August 1572 by Cardinal Benedetto Lomellini assisted by Antonio Elio, Titular Patriarch of Jerusalem, and Giovanni Ambrosio Fieschi, Bishop of Savona.
Pope Gregory XIII made him a cardinal priest in the consistory of 21 February 1578. He received the red hat and the titular church of Santa Maria in Aracoeli on 3 March 1578. Along with Cardinal Francesco Crasso and other prelates, he was charged with reforming the Roman Curia. On 23 March 1580 he was named legate a latere before Philip II of Spain. He became Prefect of the Apostolic Signatura in May 1581. He became legate a latere to the Kingdom of Portugal on 25 October 1581 and served as legate a latere in Perugia and Umbria from 25 October 1581 to 1583. He participated in the papal conclave of 1585 that elected Pope Sixtus V.