After the death of the last Valois King, Henry III, a Civil War broke out. The next heir to the Throne was Henry of Navarre, who was married to Marguerite of France (daughter of Henry II and sister to Francois II, Charles IX and Henry III).
On the death of Henri III, Henri of Navarre nominally became the king of France. But the Catholic League didn't want a Huguenot as a King. Catholics were supported by Spain; Henry was mainly on his own with only insignificant support from Elizabeth I of England. The League proclaimed Henry's Catholic uncle King Charles X, but after Charles's death, the League could not agree on a new candidate.
Some supported Guise candidates: the late Henri, duke de Guise had a widespread support, but after his death none of his relatives had the same popularity. The other strong candidate was Infanta Isabella, the daughter of Philip II of Spain, whose mother Elisabeth had been the eldest daughter of Henri II of France (this despite the fact that females could not succeed to the French Throne, and in any case, Henry of Navarre was married to the daughter of Henry II himself).
Despite victories, Henry remained unable to take control of Paris. That's when, on July 25, 1593, Henri declared that "Paris vaut bein une messe" ("Paris is well worth a Mass") and renounced Protestantism. That was not the first time - he had converted to Catholicism twice before, only to return to Protestantism later; however, that was his last conversion.
His entrance into the Roman Catholic Church secured for him the allegiance of the vast majority of his subjects, and he was crowned King of France at the Cathedral of Chartres on 27 February 1594.
To secure peace in the Kingdom, torn by religious differences, he declared the Edict of Nantes, which gave circumscribed toleration to the Huguenots. Th Edict was later to be cancelled during the reign of his grandson, Louis XIV.