legally
Word family
Synonym discussion
Sense: adverb/1
'Lawfully' is the closest synonym to 'legally' in sense 1, but it appears more often in formal legal writing and courtroom language — a judge rules that evidence was 'lawfully obtained.' 'Legitimately' is broader: it can refer to something that is morally, logically, or socially acceptable, not just legally compliant. For example, you can 'legitimately complain' about bad service even when no law is involved. 'By the book' is an informal idiom that means following rules strictly, but those rules may be company policy or procedure rather than actual law. In practice: 'The contractor completed the work legally (within the law) but did not follow the building specifications by the book (per the contract's procedures).'
Etymology
From Latin 'legalis' meaning 'pertaining to the law,' via French 'légal' and Middle English, with the '-ly' suffix forming an adverb.