I have been taught that the stress in classical Latin is on the second last syllable if it is long and on the third last syllable otherwise. In two-syllable words the stress is on the first syllable. How do we know this? Did the Romans write about this, or did we deduce it based on later forms of Latin or Romance languages? This prose stress system is very different from poetic meters and seems to be unrelated. See this question for exceptions to the stress rules.
W. Sidney Allen in Vox Latina says that various grammarians such as Quintilian stated the rules quite unambiguously (although he also writes that "there is some controversy about the nature of the historical accent").
However, even if we didn't have precise statements from ancient grammarians, the rules could pretty easily deduced simply from the reflexes of Latin words in the modern Romance languages. For example, Spanish dueño certainly points to a Latin dóminus rather than domínus, and French vierge points to vírgine(m) rather than virgíne(m).
So, the answer is both - we have explicit testimony and also the evidence of the Romance languages.