CORS (Cross-Origin Resource Sharing) is a security feature implemented by web browsers to allow or restrict web applications running at one origin from accessing resources at a different origin, thereby preventing unauthorized access and ensuring data integrity. By using HTTP headers, CORS enables servers to specify who can access their resources and which HTTP methods are allowed, providing a controlled way to handle cross-origin requests.