A library is reusable code that performs a specific function and does not provide ways to extend it, while a framework provides structure for a project and callbacks for developers to build on top of the framework. Libraries focus on single functions through an API, but frameworks dictate architecture and provide hooks to integrate additional code.