Dependency injection is a technique where objects receive their dependencies from external sources rather than creating them themselves. It decouples classes from their dependencies and allows dependencies to be replaced without modifying the dependent class. A dependency injection container creates and maps dependencies, providing them to classes through constructor or property injection according to how they are configured in the container.