This answer is about the case of complex surfaces $X$ and their diffeomorphisms (all my diffeos are assumed to be orientation-preserving!).

**(1) Examples of self-diffeomorphisms that reverse the sign of the canonical class.**

Take $X=\mathbb{C}P^1\times \mathbb{C}P^1$. Let $\tau$ be reflection in the equator of $S^2=\mathbb{C}P^1$. Then $\tau \times \tau$ preserves orientation and acts as $-I$ on $H^2(X)$. It therefore sends $K_X$ to $-K_X$.

One can also realise the automorphism $-I$ of $H^2(X)$ by a diffeomorphism when $X$ is the blow-up of the projective plane at $k$ points, $k = 2,3,\dots,9$. This follows from a result of C.T.C. Wall from

*Diffeomorphisms of 4-manifolds*, J. London Math. Soc. 39 (1964) 131–140, MR0163323

Wall says that if $N$ is a simply connected, closed oriented 4-manifold with $b_2(N)<9$, and $X$ is the connected sum of $N$ with $S^2 \times S^2$, then all automorphisms of the intersection form of $X$ are realised by diffeos. To apply this, recall that the 1-point blow-up of $\mathbb{C}P^1\times \mathbb{C}P^1$ is the 2-point blow up of the projective plane. (Wall's strategy, by the way, is to factor the automorphism into reflections along hyperplanes, and to realise those.)

**(2) Results from Seiberg-Witten theory.**

These results tie complex geometry amazingly closely to differential topology. They say that the unsigned pair $\pm K_X$ is invariant under diffeomorphisms (Witten http://arxiv.org/abs/hep-th/9411102 and others); so too is the Kodaira dimension; so too are the plurigenera (Friedman-Morgan http://arxiv.org/abs/alg-geom/9502026).

In Kodaira dimension $<2$, one can take this further and prove that oriented-diffeomorphic surfaces are actually deformation-equivalent (to be safe, let me specify the simply connected case). But that's *not* the explanation in general: there are pairs of simply connected general-type surfaces that are diffeomorphic (by diffeos preserving the canonical class), which are not deformation-equivalent (Catanese-Wajnryb http://arxiv.org/abs/math/0405299).

**(3) How it happens.**

The Seiberg-Witten invariant (for an oriented 4-manifold with $b^+(X)>1$) is a map
$$SW: Spin^c(X)\to\mathbb{Z}$$
defined on the $H^2(X)$-torsor of $Spin^c$-structures. The overall sign is equivalent to a "homology orientation". It's natural under diffeomorphisms. It's also invariant under "conjugation" $\mathfrak{s}\mapsto \bar{\mathfrak{s}}$ of $Spin^c$-structures.

For algebraic surfaces, there's a canonical spin-c structure $\mathfrak{s}$, so $Spin^c(X)$ is identified with $H^2(X)$. Witten (http://arxiv.org/abs/hep-th/9411102) observed that the elliptic equations that define $SW$ simplify drastically in the algebraic case; in evaluating $SW$ on a cohomology class represented by a complex line bundle $L\to X$, you're led to consider a moduli space of pairs consisting of a holomorphic structure on the line bundle and a holomorphic section of it, with an obstruction bundle on the moduli space. Conjugation-invariance becomes Serre duality.

For general type surfaces, $\pm SW(\mathfrak{s}) = \pm SW(\bar{\mathfrak{s}}) = \pm 1$; all other spin-c structures have vanishing invariant. Since $c_1(\mathfrak{s})=-c_1(\bar{\mathfrak{s}})=-K$, one deduces diffeomorphism-invariance of $\pm K$. For lower Kodaira dimension, a more complicated analysis is needed.

yesif the diffeomorphism is induced by a deformation equivalence; this is an easy consequence of Ehresmann theorem. Otherwise, I think that the answer is not at all obvious. For instance, using Seiberg Witten theory, one proves that any diffeomorphism $\phi \colon X \to X'$ between smooth $4$-manifolds (for instance, algebraic surfaces) maps $K_X$ either into $K_{X'}$ or into $-K_{X'}$, and the second casemay occur. I do not know, however, if there are examples where the second case occurs and $X$, $Y'$ are both smooth and projective. – Francesco Polizzi Jul 15 '11 at 13:23